Prechádzať zdrojové kódy

hmac_md5: Fix invalid parameter to memset

C99 §7.21.1 specify that even when called with a size of 0, memset shall
still be called with a valid pointer, which isn't the case when the
pointer is key_pad + 64.
fix cid #65530

Signed-off-by: Thomas Guillem <thomas@gllm.fr>
Hugo Beauzée-Luyssen 9 rokov pred
rodič
commit
a08846f817
1 zmenil súbory, kde vykonal 2 pridanie a 1 odobranie
  1. 2 1
      src/hmac_md5.c

+ 2 - 1
src/hmac_md5.c

@@ -51,7 +51,8 @@ unsigned char *HMAC_MD5(const void *key, size_t key_len, const void *msg,
         key_len = 64;
 
     memcpy(key_pad, key, key_len);
-    memset(key_pad + key_len, 0, 64 - key_len);
+    if (key_len < 64)
+        memset(key_pad + key_len, 0, 64 - key_len);
 
     // Compute the o/i XORed padded keys
     for (unsigned i = 0; i < 64; i++)