From 0599c5f546c8b3e04c0dd9fcdc19a6b3825849a7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 17 Nov 2011 11:18:08 -0500 Subject: [PATCH] sha2: Zero entire SHA_CTX structure during cleanup Convert lines of the form MEMSET_BZERO(context, sizeof(context)); to the correct form MEMSET_BZERO(context, sizeof(*context)); as suggested by Clang. --- Source/cm_sha2.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c index b1798a85f..12c39ed63 100644 --- a/Source/cm_sha2.c +++ b/Source/cm_sha2.c @@ -704,7 +704,7 @@ void SHA1_Final(sha_byte digest[], SHA_CTX* context) { * No digest buffer, so we can do nothing * except clean up and go home */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); return; } @@ -760,7 +760,7 @@ void SHA1_Final(sha_byte digest[], SHA_CTX* context) { #endif /* Clean up: */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA1_End(SHA_CTX* context, char buffer[]) { @@ -780,7 +780,7 @@ char *SHA1_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA1_DIGEST_LENGTH); return buffer; @@ -1099,7 +1099,7 @@ void SHA256_Final(sha_byte digest[], SHA_CTX* context) { } /* Clean up state data: */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA256_End(SHA_CTX* context, char buffer[]) { @@ -1119,7 +1119,7 @@ char *SHA256_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA256_DIGEST_LENGTH); return buffer; @@ -1173,7 +1173,7 @@ void SHA224_Final(sha_byte digest[], SHA_CTX* context) { } /* Clean up state data: */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA224_End(SHA_CTX* context, char buffer[]) { @@ -1193,7 +1193,7 @@ char *SHA224_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA224_DIGEST_LENGTH); return buffer; @@ -1508,7 +1508,7 @@ void SHA512_Final(sha_byte digest[], SHA_CTX* context) { } /* Zero out state data */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA512_End(SHA_CTX* context, char buffer[]) { @@ -1528,7 +1528,7 @@ char *SHA512_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA512_DIGEST_LENGTH); return buffer; @@ -1578,7 +1578,7 @@ void SHA384_Final(sha_byte digest[], SHA_CTX* context) { } /* Zero out state data */ - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } char *SHA384_End(SHA_CTX* context, char buffer[]) { @@ -1598,7 +1598,7 @@ char *SHA384_End(SHA_CTX* context, char buffer[]) { } *buffer = (char)0; } else { - MEMSET_BZERO(context, sizeof(context)); + MEMSET_BZERO(context, sizeof(*context)); } MEMSET_BZERO(digest, SHA384_DIGEST_LENGTH); return buffer;