]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
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:37:41 +0000 (10:37 +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)

(cherry picked from commit bc6bac8561ead83d6135f376ffcbbb0b657e64fe)

crypto/bn/bn_div.c

index 0da9f39b31a93dd71d0ee3a1f96a03ee8aa95476..e2821fb6cd2281197ac917e01d5e5fcf2b9113cf 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: