]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Make crypto_hash_init() easier for static analyzers
authorJouni Malinen <j@w1.fi>
Sun, 13 Nov 2011 21:19:19 +0000 (23:19 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 13 Nov 2011 21:19:19 +0000 (23:19 +0200)
Avoid zero-length memset at the end of the buffer. This is not really
needed, but it makes the code a bit easier for static analyzers.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/crypto/crypto_internal.c

index 8fdba65802750d2a374919f3bed0e62e93ced2a0..955cd55650032dce76749a7c01bff07471323ba1 100644 (file)
@@ -63,7 +63,8 @@ struct crypto_hash * crypto_hash_init(enum crypto_hash_alg alg, const u8 *key,
                ctx->key_len = key_len;
 
                os_memcpy(k_pad, key, key_len);
-               os_memset(k_pad + key_len, 0, sizeof(k_pad) - key_len);
+               if (key_len < sizeof(k_pad))
+                       os_memset(k_pad + key_len, 0, sizeof(k_pad) - key_len);
                for (i = 0; i < sizeof(k_pad); i++)
                        k_pad[i] ^= 0x36;
                MD5Init(&ctx->u.md5);