don't write beyond buffer
[oweals/openssl.git] / crypto / bn / bn_shift.c
index 37c6988da3dfdb1d358855a1a1d3802e3d554837..70f785ea185b8841e415d33b385bf96de95535be 100644 (file)
@@ -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;