X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fbn%2Fbn_shift.c;h=4e43a60b22944b81e3d4e0c74e4628d39c99cc51;hb=d911097d7c93e4cfeab624b34d73fe51da158b69;hp=9895646afaafce9ef5229425aac41bfc8a98f7c3;hpb=16f8d4ebf0fd4847fa83d9c61f4150273cb4f533;p=oweals%2Fopenssl.git diff --git a/crypto/bn/bn_shift.c b/crypto/bn/bn_shift.c index 9895646afa..4e43a60b22 100644 --- a/crypto/bn/bn_shift.c +++ b/crypto/bn/bn_shift.c @@ -56,7 +56,7 @@ * [including the GNU Public Licence.] */ -#include "cryptlib.h" +#include "internal/cryptlib.h" #include "bn_lcl.h" int BN_lshift1(BIGNUM *r, const BIGNUM *a) @@ -136,6 +136,11 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n) bn_check_top(r); bn_check_top(a); + if (n < 0) { + BNerr(BN_F_BN_LSHIFT, BN_R_INVALID_SHIFT); + return 0; + } + r->neg = a->neg; nw = n / BN_BITS2; if (bn_wexpand(r, a->top + nw + 1) == NULL) @@ -170,6 +175,11 @@ int BN_rshift(BIGNUM *r, const BIGNUM *a, int n) bn_check_top(r); bn_check_top(a); + if (n < 0) { + BNerr(BN_F_BN_RSHIFT, BN_R_INVALID_SHIFT); + return 0; + } + nw = n / BN_BITS2; rb = n % BN_BITS2; lb = BN_BITS2 - rb;