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 #17237

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from #17240)

(cherry picked from commit 858d5ac)
  • Loading branch information
t8m committed Dec 13, 2021
1 parent bfa90fc commit 110b005
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 110b005

Please sign in to comment.