summaryrefslogtreecommitdiffstats
path: root/crypto/bn
diff options
context:
space:
mode:
authorTomas Mraz <tmraz@fedoraproject.org>2020-05-19 10:51:53 +0200
committerTomas Mraz <tmraz@fedoraproject.org>2020-05-20 17:58:06 +0200
commit5156ecbe691c964ae528c74f94d5b515aeb25542 (patch)
treef1dc99b276e6c00d0acf6e48a6a97552173d461a /crypto/bn
parente11072908742e96a1067bb1b9609bfc27ab05835 (diff)
Avoid potential overflow to the sign bit when shifting left 24 places
Although there are platforms where int is 64 bit, 2GiB large BIGNUMs instead of 4GiB should be "big enough for everybody". Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11857) (cherry picked from commit 1d05eb55caa8965a151360c2469c463ecd990987)
Diffstat (limited to 'crypto/bn')
-rw-r--r--crypto/bn/bn_mpi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/bn/bn_mpi.c b/crypto/bn/bn_mpi.c
index bdbe822415..b6e35a8ed9 100644
--- a/crypto/bn/bn_mpi.c
+++ b/crypto/bn/bn_mpi.c
@@ -45,7 +45,7 @@ BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *ain)
int neg = 0;
BIGNUM *a = NULL;
- if (n < 4) {
+ if (n < 4 || (d[0] & 0x80) != 0) {
BNerr(BN_F_BN_MPI2BN, BN_R_INVALID_LENGTH);
return NULL;
}