From 1e8de8872bb38ecfb55ccdd972f30214141fd7ce Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Fri, 11 Aug 2023 11:51:15 +0100 Subject: [PATCH] Don't call ossl_assert on the result of bn_wexpand bn_wexpand can fail as the result of a memory allocation failure. We should not be calling ossl_assert() on its result because it can fail in normal operation. Found via the reproducible error injection in #21668 --- crypto/bn/bn_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index e810647f578fa..1b8d47a28166d 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -504,7 +504,7 @@ static BIGNUM *bin2bn(const unsigned char *s, int len, BIGNUM *ret, return ret; } n = ((len - 1) / BN_BYTES) + 1; /* Number of resulting bignum chunks */ - if (!ossl_assert(bn_wexpand(ret, (int)n) != NULL)) { + if (bn_wexpand(ret, (int)n) == NULL) { BN_free(bn); return NULL; }