summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2013-01-02 20:58:46 +0000
committerdelphij <delphij@FreeBSD.org>2013-01-02 20:58:46 +0000
commit339eb8a5c4867651f114cf983f2fe46116b28e7b (patch)
tree3981cf30ae18ed23103ece78fb454f7273034f0b /crypto
parentc7de6a7866a6cc1967458d51a30c0c83ab5096c7 (diff)
downloadFreeBSD-src-339eb8a5c4867651f114cf983f2fe46116b28e7b.zip
FreeBSD-src-339eb8a5c4867651f114cf983f2fe46116b28e7b.tar.gz
MFV r244973:
Integrate OpenSSL changeset 22950 (appro): bn_word.c: fix overflow bug in BN_add_word. MFC after: 2 weeks
Diffstat (limited to 'crypto')
-rw-r--r--crypto/openssl/crypto/bn/bn_word.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/crypto/openssl/crypto/bn/bn_word.c b/crypto/openssl/crypto/bn/bn_word.c
index ee7b87c..de83a15 100644
--- a/crypto/openssl/crypto/bn/bn_word.c
+++ b/crypto/openssl/crypto/bn/bn_word.c
@@ -144,26 +144,17 @@ int BN_add_word(BIGNUM *a, BN_ULONG w)
a->neg=!(a->neg);
return(i);
}
- /* Only expand (and risk failing) if it's possibly necessary */
- if (((BN_ULONG)(a->d[a->top - 1] + 1) == 0) &&
- (bn_wexpand(a,a->top+1) == NULL))
- return(0);
- i=0;
- for (;;)
+ for (i=0;w!=0 && i<a->top;i++)
{
- if (i >= a->top)
- l=w;
- else
- l=(a->d[i]+w)&BN_MASK2;
- a->d[i]=l;
- if (w > l)
- w=1;
- else
- break;
- i++;
+ a->d[i] = l = (a->d[i]+w)&BN_MASK2;
+ w = (w>l)?1:0;
}
- if (i >= a->top)
+ if (w && i==a->top)
+ {
+ if (bn_wexpand(a,a->top+1) == NULL) return 0;
a->top++;
+ a->d[i]=w;
+ }
bn_check_top(a);
return(1);
}
OpenPOWER on IntegriCloud