]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dsdb:password_hash: move hash_blob allocation up
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 11 Dec 2024 01:29:21 +0000 (14:29 +1300)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 20 Dec 2024 07:04:31 +0000 (07:04 +0000)
This will make the next patch simpler.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15756

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
source4/dsdb/samdb/ldb_modules/password_hash.c

index 1d1267624e2c02f6746ce39484e5e93b72c75833..c1902126a720317d03cd77763322a057b017a223 100644 (file)
@@ -1649,6 +1649,13 @@ static int setup_primary_userPassword_hash(
                }
        }
 
+       hash_blob = talloc_zero(ctx, DATA_BLOB);
+
+       if (hash_blob == NULL) {
+               TALLOC_FREE(frame);
+               return ldb_oom(ldb);
+       }
+
        /*
         * Relies on the assertion that cleartext_utf8->data is a zero
         * terminated UTF-8 string
@@ -1712,15 +1719,10 @@ static int setup_primary_userPassword_hash(
                        scheme,
                        reason);
                TALLOC_FREE(frame);
+               TALLOC_FREE(hash_blob);
                return LDB_ERR_OPERATIONS_ERROR;
        }
 
-       hash_blob = talloc_zero(ctx, DATA_BLOB);
-
-       if (hash_blob == NULL) {
-               TALLOC_FREE(frame);
-               return ldb_oom(ldb);
-       }
 
        *hash_blob =  data_blob_talloc(hash_blob,
                                       (const uint8_t *)hash,