]> jfr.im git - irc/atheme/atheme.git/commitdiff
modules/crypto/pbkdf2v2: remove unnecessary memset(3) calls
authorAaron Jones <redacted>
Sat, 7 Oct 2017 14:35:45 +0000 (14:35 +0000)
committerAaron Jones <redacted>
Sat, 7 Oct 2017 22:05:38 +0000 (22:05 +0000)
These are left over from module development where they made
debugging easier.

modules/crypto/pbkdf2v2.c

index b857d9034e5ecd0c589d9fa1163bdf4d6571d44e..3e7a2f76e6574c22c6fb252ba540aee815b1b32e 100644 (file)
@@ -55,12 +55,12 @@ static const char *pbkdf2v2_make_salt(void)
        char            salt[PBKDF2_SALTLEN + 1];
        static char     result[PASSLEN];
 
-       memset(salt, 0x00, sizeof salt);
-       memset(result, 0x00, sizeof result);
-
        for (int i = 0; i < PBKDF2_SALTLEN; i++)
                salt[i] = salt_chars[arc4random() % sizeof salt_chars];
 
+       /* NULL-terminate the string */
+       salt[PBKDF2_SALTLEN] = 0x00;
+
        (void) snprintf(result, sizeof result, PBKDF2_F_SALT,
                        pbkdf2v2_digest, pbkdf2v2_rounds, salt);
 
@@ -112,12 +112,10 @@ static const char *pbkdf2v2_crypt(const char *pass, const char *crypt_str)
                                 iter, md, EVP_MD_size(md), digest);
 
        /* Convert the digest to Base 64 */
-       memset(digest_b64, 0x00, sizeof digest_b64);
        (void) base64_encode((const char *) digest, EVP_MD_size(md),
                             digest_b64, sizeof digest_b64);
 
        /* Format the result */
-       memset(result, 0x00, sizeof result);
        (void) snprintf(result, sizeof result, PBKDF2_F_PRINT,
                        prf, iter, salt, digest_b64);