dbwrap: completely check validity of lock order in dbwrap_check_lock_order()
authorMichael Adam <obnox@samba.org>
Mon, 27 Jan 2014 16:34:31 +0000 (17:34 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 7 Feb 2014 15:06:07 +0000 (16:06 +0100)
This is currently not strictly necessay, because the
only caller catches the DBWRAP_LOCK_ORDER_NONE case,
and maximum is already checked,  but this seems too dangerous to me.

Use the new DBWRAP_LOCK_ORDER_VALID() macro.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/dbwrap/dbwrap.c

index 3606617e2e82f16011960aee5f93ff7cb48d6e9f..d75c714ef1fe41577757be6fb37f56f4ba8b9fd4 100644 (file)
@@ -167,7 +167,7 @@ static struct dbwrap_lock_order_state *dbwrap_check_lock_order(
        static struct db_context *locked_dbs[DBWRAP_LOCK_ORDER_MAX];
        struct dbwrap_lock_order_state *state = NULL;
 
-       if (db->lock_order > DBWRAP_LOCK_ORDER_MAX) {
+       if (!DBWRAP_LOCK_ORDER_VALID(db->lock_order)) {
                DEBUG(0,("Invalid lock order %d of %s\n",
                         (int)db->lock_order, db->name));
                smb_panic("invalid lock_order\n");