X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fbn%2Fbn_shift.c;h=70f785ea185b8841e415d33b385bf96de95535be;hp=e4da833ea67f33aa68b22a7dde588ca182034358;hb=e815d3015eba4e54f414636b8907e15e249d72cf;hpb=020fc820dc90dbbcf0d7e3f3345af9e44cf905a7 diff --git a/crypto/bn/bn_shift.c b/crypto/bn/bn_shift.c index e4da833ea6..70f785ea18 100644 --- a/crypto/bn/bn_shift.c +++ b/crypto/bn/bn_shift.c @@ -128,8 +128,8 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n) BN_ULONG l; r->neg=a->neg; - if (bn_wexpand(r,a->top+(n/BN_BITS2)+1) == NULL) return(0); nw=n/BN_BITS2; + if (bn_wexpand(r,a->top+nw+1) == NULL) return(0); lb=n%BN_BITS2; rb=BN_BITS2-lb; f=a->d; @@ -172,6 +172,11 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n) r->neg=a->neg; if (bn_wexpand(r,a->top-nw+1) == NULL) return(0); } + else + { + if (n == 0) + return 1; /* or the copying loop will go berserk */ + } f= &(a->d[nw]); t=r->d;