Skip to content

Commit 22a8118

Browse files
DarkDeepBlueherbertx
authored andcommitted
crypto: testmgr - fix sizeof() on COMP_BUF_SIZE
After allocation, output and decomp_output both point to memory chunks of size COMP_BUF_SIZE. Then, only the first bytes are zeroed out using sizeof(COMP_BUF_SIZE) as parameter to memset(), because sizeof(COMP_BUF_SIZE) provides the size of the constant and not the size of allocated memory. Instead, the whole allocated memory is meant to be zeroed out. Use COMP_BUF_SIZE as parameter to memset() directly in order to accomplish this. Fixes: 3360738 ("crypto: testmgr - Allow different compression results") Signed-off-by: Michael Schupikov <michael@schupikov.de> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent cb1af1f commit 22a8118

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crypto/testmgr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,8 +1400,8 @@ static int test_comp(struct crypto_comp *tfm,
14001400
int ilen;
14011401
unsigned int dlen = COMP_BUF_SIZE;
14021402

1403-
memset(output, 0, sizeof(COMP_BUF_SIZE));
1404-
memset(decomp_output, 0, sizeof(COMP_BUF_SIZE));
1403+
memset(output, 0, COMP_BUF_SIZE);
1404+
memset(decomp_output, 0, COMP_BUF_SIZE);
14051405

14061406
ilen = ctemplate[i].inlen;
14071407
ret = crypto_comp_compress(tfm, ctemplate[i].input,
@@ -1445,7 +1445,7 @@ static int test_comp(struct crypto_comp *tfm,
14451445
int ilen;
14461446
unsigned int dlen = COMP_BUF_SIZE;
14471447

1448-
memset(decomp_output, 0, sizeof(COMP_BUF_SIZE));
1448+
memset(decomp_output, 0, COMP_BUF_SIZE);
14491449

14501450
ilen = dtemplate[i].inlen;
14511451
ret = crypto_comp_decompress(tfm, dtemplate[i].input,

0 commit comments

Comments
 (0)