Skip to content

Commit eaa5120

Browse files
committed
ext/gmp: Fix crash in gmp_pow with excessively large exponent
1 parent 666fe16 commit eaa5120

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

ext/gmp/gmp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#define GMP_LITTLE_ENDIAN (1 << 2)
4949
#define GMP_BIG_ENDIAN (1 << 3)
5050
#define GMP_NATIVE_ENDIAN (1 << 4)
51-
#define GMP_POW_MAX_EXP 1000000L
5251

5352
#include "gmp_arginfo.h"
5453

@@ -1140,7 +1139,7 @@ ZEND_FUNCTION(gmp_pow)
11401139

11411140
bits = mpz_sizeinbase(gmpnum_base, 2);
11421141

1143-
if (exp < 0 || exp > (SIZE_MAX - 5) / bits) {
1142+
if (exp > (SIZE_MAX - 5) / bits) {
11441143
zend_argument_value_error(2, "results in a value that exceeds the supported size");
11451144
RETURN_THROWS();
11461145
}

0 commit comments

Comments
 (0)