]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dsdb: Simplification with generate_random_str_list_buf()
authorVolker Lendecke <vl@samba.org>
Sun, 29 Dec 2024 10:54:38 +0000 (11:54 +0100)
committerJeremy Allison <jra@samba.org>
Thu, 23 Jan 2025 23:08:38 +0000 (23:08 +0000)
No NULL check required

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source4/dsdb/samdb/ldb_modules/password_hash.c

index 6949a92fc3e790490a66f4f653ade34fad26d2ea..c028e72bea4a296d3becadf62720d18df13dc372 100644 (file)
@@ -1591,7 +1591,7 @@ static int setup_primary_userPassword_hash(
        struct package_PrimaryUserPasswordValue *hash_value)
 {
        struct ldb_context *ldb = ldb_module_get_ctx(io->ac->module);
-       const char *salt = NULL;        /* Randomly generated salt */
+       char salt[SHA_SALT_SIZE + 1];   /* Randomly generated salt */
        const char *cmd = NULL;         /* command passed to crypt */
        int algorithm = 0;              /* crypt hash algorithm number */
        int rounds = 0;                 /* The number of hash rounds */
@@ -1600,13 +1600,9 @@ static int setup_primary_userPassword_hash(
        TALLOC_CTX *frame = talloc_stackframe();
 
        /* Generate a random password salt */
-       salt = generate_random_str_list(frame,
-                                       SHA_SALT_SIZE,
-                                       SHA_SALT_PERMITTED_CHARS);
-       if (salt == NULL) {
-               TALLOC_FREE(frame);
-               return ldb_oom(ldb);
-       }
+       generate_random_str_list_buf(salt,
+                                    sizeof(salt),
+                                    SHA_SALT_PERMITTED_CHARS);
 
        /* determine the hashing algorithm and number of rounds*/
        if (!parse_scheme(scheme, &algorithm, &rounds)) {