From: Jouni Malinen Date: Sun, 13 Nov 2011 21:24:08 +0000 (+0200) Subject: Make crypto_hash_init() easier for static analyzers X-Git-Tag: aosp-jb-start~336 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f2e2e369b4ebc3bc609f1eba865300374397b3f;p=thirdparty%2Fhostap.git Make crypto_hash_init() easier for static analyzers 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 --- diff --git a/src/crypto/crypto_internal.c b/src/crypto/crypto_internal.c index 955cd5565..5f715a831 100644 --- a/src/crypto/crypto_internal.c +++ b/src/crypto/crypto_internal.c @@ -82,7 +82,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; SHA1Init(&ctx->u.sha1);