Skip to content

Commit

Permalink
bn2binpad: Use memset as the buffer will be used later
Browse files Browse the repository at this point in the history
Apparently using OPENSSL_cleanse() confuses the fuzzer so it
makes the buffer to appear uninitialized. And memset can be
safely used here and it is also potentially faster.

Fixes openssl#17237

Reviewed-by: Bernd Edlinger <[email protected]>
(Merged from openssl#17240)
  • Loading branch information
t8m committed Dec 13, 2021
1 parent 61fa00a commit 858d5ac
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crypto/bn/bn_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ int bn2binpad(const BIGNUM *a, unsigned char *to, int tolen, endianess_t endiane
/* Swipe through whole available data and don't give away padded zero. */
atop = a->dmax * BN_BYTES;
if (atop == 0) {
OPENSSL_cleanse(to, tolen);
if (tolen != 0)
memset(to, '\0', tolen);
return tolen;
}

Expand Down

0 comments on commit 858d5ac

Please sign in to comment.