Skip to content

Commit

Permalink
Don't call ossl_assert on the result of bn_wexpand
Browse files Browse the repository at this point in the history
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 openssl#21668
  • Loading branch information
mattcaswell committed Aug 11, 2023
1 parent f260900 commit 1e8de88
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/bn/bn_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1e8de88

Please sign in to comment.