From: Aki Tuomi Date: Thu, 20 Aug 2020 05:47:16 +0000 (+0300) Subject: auth: password-scheme - Fix salt generation data type mess X-Git-Tag: 2.3.13~202 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a0ea53c31368a1b0054b32a91853c78c6c9b9fc9;p=thirdparty%2Fdovecot%2Fcore.git auth: password-scheme - Fix salt generation data type mess Satisfies runtime analyser --- diff --git a/src/auth/password-scheme.c b/src/auth/password-scheme.c index f0c789e3f7..e22cb3f88a 100644 --- a/src/auth/password-scheme.c +++ b/src/auth/password-scheme.c @@ -246,13 +246,10 @@ bool password_generate_encoded(const char *plaintext, const struct password_gene const char *password_generate_salt(size_t len) { - unsigned int i; char *salt; - salt = t_malloc_no0(len + 1); - random_fill(salt, len); - for (i = 0; i < len; i++) - salt[i] = salt_chars[salt[i] % (sizeof(salt_chars)-1)]; + for (size_t i = 0; i < len; i++) + salt[i] = salt_chars[i_rand_limit(sizeof(salt_chars) - 1)]; salt[len] = '\0'; return salt; }