Skip to content

Commit

Permalink
Avoid potential overflow to the sign bit when shifting left 24 places
Browse files Browse the repository at this point in the history
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 #11857)
  • Loading branch information
t8m committed May 20, 2020
1 parent cbeb0bf commit 1d05eb5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crypto/bn/bn_mpi.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1d05eb5

Please sign in to comment.