From: Tomas Mraz Date: Wed, 8 Dec 2021 17:26:03 +0000 (+0100) Subject: bn2binpad: Use memset as the buffer will be used later X-Git-Tag: openssl-3.2.0-alpha1~3215 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=858d5ac16d256db24f78b8c84e723b7d34c8b1ea;p=thirdparty%2Fopenssl.git bn2binpad: Use memset as the buffer will be used later 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 (Merged from https://github.com/openssl/openssl/pull/17240) --- diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index 28a3e91679d..d37b89c2a6e 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -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; }