From: Michael Olbrich Date: Tue, 5 May 2015 23:40:01 +0200 Subject: [PATCH] fix incorrect memcpy()/memset() size argument Arrays as function arguments are realy pointers so sizeof(digest) == sizeof(unsigned char*) != 20 Signed-off-by: Michael Olbrich --- src/rmd160.c | 2 +- src/sha.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rmd160.c b/src/rmd160.c index ec047fe33b28..87d9674aab0b 100644 --- a/src/rmd160.c +++ b/src/rmd160.c @@ -444,5 +444,5 @@ RMD160Final (unsigned char digest[20], RMD160_CTX * ctx) digest[i * 4 + 3] = (u_int8_t) (t >> 24); } - memset (ctx, 0, sizeof (ctx)); /* In case it's sensitive */ + memset (ctx, 0, sizeof (*ctx)); /* In case it's sensitive */ } diff --git a/src/sha.c b/src/sha.c index 779ace1de031..d24c5537d8ac 100644 --- a/src/sha.c +++ b/src/sha.c @@ -344,7 +344,7 @@ SHAFinal (unsigned char digest[20], SHA_CTX * ctx) #endif SHATransform (ctx); - memcpy (digest, ctx->iv, sizeof (digest)); + memcpy (digest, ctx->iv, 20); for (i = 0; i < SHA_HASHWORDS; i++) { t = ctx->iv[i]; @@ -354,5 +354,5 @@ SHAFinal (unsigned char digest[20], SHA_CTX * ctx) digest[i * 4 + 3] = (u_int8_t) t; } - memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ }