Skip to content

Commit

Permalink
crypto: testmgr - fix sizeof() on COMP_BUF_SIZE
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Schupikov authored and Herbert Xu committed Oct 12, 2018
1 parent cb1af1f commit 22a8118
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crypto/testmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,8 +1400,8 @@ static int test_comp(struct crypto_comp *tfm,
int ilen;
unsigned int dlen = COMP_BUF_SIZE;

memset(output, 0, sizeof(COMP_BUF_SIZE));
memset(decomp_output, 0, sizeof(COMP_BUF_SIZE));
memset(output, 0, COMP_BUF_SIZE);
memset(decomp_output, 0, COMP_BUF_SIZE);

ilen = ctemplate[i].inlen;
ret = crypto_comp_compress(tfm, ctemplate[i].input,
Expand Down Expand Up @@ -1445,7 +1445,7 @@ static int test_comp(struct crypto_comp *tfm,
int ilen;
unsigned int dlen = COMP_BUF_SIZE;

memset(decomp_output, 0, sizeof(COMP_BUF_SIZE));
memset(decomp_output, 0, COMP_BUF_SIZE);

ilen = dtemplate[i].inlen;
ret = crypto_comp_decompress(tfm, dtemplate[i].input,
Expand Down

0 comments on commit 22a8118

Please sign in to comment.