bn/bn_mod.c: harmonize BN_mod_add_quick with original implementation.
authorAndy Polyakov <appro@openssl.org>
Wed, 25 Jul 2018 08:29:51 +0000 (10:29 +0200)
committerAndy Polyakov <appro@openssl.org>
Thu, 26 Jul 2018 11:56:05 +0000 (13:56 +0200)
New implementation failed to correctly reset r->neg flag. Spotted by
OSSFuzz.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6783)

crypto/bn/bn_mod.c

index 463d2d69a88a83d2af460f150b1503252fdcac75..d8e2e12c1e0949065dbf28ccb0f41ca64d349873 100644 (file)
@@ -83,6 +83,7 @@ int bn_mod_add_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b,
         ((volatile BN_ULONG *)tp)[i] = 0;
     }
     r->top = mtop;
+    r->neg = 0;
 
     if (tp != storage)
         OPENSSL_free(tp);