]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: password-scheme - Fix salt generation data type mess
authorAki Tuomi <aki.tuomi@open-xchange.com>
Thu, 20 Aug 2020 05:47:16 +0000 (08:47 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 11 Sep 2020 07:07:20 +0000 (07:07 +0000)
Satisfies runtime analyser

src/auth/password-scheme.c

index f0c789e3f7cd7c281375d0928e72a16c2b8bd3a7..e22cb3f88aad3864c913e3bdf6cf3f7344ceca72 100644 (file)
@@ -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;
 }