Fix failure to check result of bn_rshift_fixed_top
authorHugo Landau <hlandau@openssl.org>
Mon, 4 Apr 2022 11:25:16 +0000 (12:25 +0100)
committerPauli <pauli@openssl.org>
Thu, 7 Apr 2022 00:36:30 +0000 (10:36 +1000)
Fixes #18010.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18034)

crypto/bn/bn_div.c

index 25514c05f11137afcf2f46ccd332ee61bac9eceb..ec6c532e4e66736fe18640b1af6a82a9ad5bd5e9 100644 (file)
@@ -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: