From: Hugo Landau Date: Mon, 4 Apr 2022 11:25:16 +0000 (+0100) Subject: Fix failure to check result of bn_rshift_fixed_top X-Git-Tag: openssl-3.2.0-alpha1~2781 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=bc6bac8561ead83d6135f376ffcbbb0b657e64fe Fix failure to check result of bn_rshift_fixed_top Fixes #18010. Reviewed-by: Matt Caswell Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/18034) --- diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index 25514c05f1..ec6c532e4e 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -446,8 +446,10 @@ int bn_div_fixed_top(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, snum->neg = num_neg; snum->top = div_n; snum->flags |= BN_FLG_FIXED_TOP; - if (rm != NULL) - bn_rshift_fixed_top(rm, snum, norm_shift); + + if (rm != NULL && bn_rshift_fixed_top(rm, snum, norm_shift) == 0) + goto err; + BN_CTX_end(ctx); return 1; err: