summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_div.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2001-02-28 00:51:48 +0000
committerDr. Stephen Henson <steve@openssl.org>2001-02-28 00:51:48 +0000
commit3d2e469cfab1ea3a0515bfe006319210da3ff4fb (patch)
treec83a1504d4bbf8e1450e2965abb967cd6cbde6c0 /crypto/bn/bn_div.c
parentbf401a2aef5a130ef21de4575f3a7c3d7a6f5e2a (diff)
Fix a bug which caused BN_div to produce the
wrong result if rm==num and num < 0.
Diffstat (limited to 'crypto/bn/bn_div.c')
-rw-r--r--crypto/bn/bn_div.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c
index 7bee1dcc72..bbd0994008 100644
--- a/crypto/bn/bn_div.c
+++ b/crypto/bn/bn_div.c
@@ -342,9 +342,13 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
}
if (rm != NULL)
{
+ /* Keep a copy of the neg flag in num because if rm==num
+ * BN_rshift() will overwrite it.
+ */
+ int neg = num->neg;
BN_rshift(rm,snum,norm_shift);
if (!BN_is_zero(rm))
- rm->neg = num->neg;
+ rm->neg = neg;
}
BN_CTX_end(ctx);
return(1);