From a249219c9b6d7e2bb92af92da9d75b0abc0937b7 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 29 Dec 2024 11:54:38 +0100 Subject: [PATCH] dsdb: Simplification with generate_random_str_list_buf() No NULL check required Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source4/dsdb/samdb/ldb_modules/password_hash.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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)) { -- 2.47.3