1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
From: Michael Olbrich <m.olbrich@pengutronix.de>
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 <m.olbrich@pengutronix.de>
---
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 */
}
|