bn: fix occurance of negative zero in BN_rshift1()
authorRichard Levitte <levitte@openssl.org>
Wed, 1 Feb 2017 01:29:46 +0000 (02:29 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 1 Feb 2017 01:31:41 +0000 (02:31 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/bn/bn_shift.c

index b3206028713c44d6faa31cc3460f2f308a552a82..6a1eec80af4b45522cde030dda551a82ef5b0cb2 100644 (file)
@@ -74,6 +74,8 @@ int BN_rshift1(BIGNUM *r, const BIGNUM *a)
         c = (t & 1) ? BN_TBIT : 0;
     }
     r->top = j;
+    if (!r->top)
+        r->neg = 0; /* don't allow negative zero */
     bn_check_top(r);
     return (1);
 }