From: Volker Lendecke Date: Sun, 29 Dec 2024 10:54:38 +0000 (+0100) Subject: dsdb: Simplification with generate_random_str_list_buf() X-Git-Tag: tdb-1.4.13~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a249219c9b6d7e2bb92af92da9d75b0abc0937b7;p=thirdparty%2Fsamba.git dsdb: Simplification with generate_random_str_list_buf() No NULL check required Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source4/dsdb/samdb/ldb_modules/password_hash.c b/source4/dsdb/samdb/ldb_modules/password_hash.c index 6949a92fc3e..c028e72bea4 100644 --- a/source4/dsdb/samdb/ldb_modules/password_hash.c +++ b/source4/dsdb/samdb/ldb_modules/password_hash.c @@ -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)) {