]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Don't call ossl_assert on the result of bn_wexpand
authorMatt Caswell <matt@openssl.org>
Fri, 11 Aug 2023 10:51:15 +0000 (11:51 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 14 Aug 2023 13:32:06 +0000 (14:32 +0100)
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

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/21725)

crypto/bn/bn_lib.c

index e810647f578fa7def27a04520421d9e15be689bb..1b8d47a28166d3465b5d2164c7d0e640004840ca 100644 (file)
@@ -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;
     }