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>
@@ -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++)