mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fix some int/long confusion issues in GMP
This commit is contained in:
commit
4380ba7f9c
2 changed files with 31 additions and 1 deletions
|
@ -1637,7 +1637,7 @@ ZEND_FUNCTION(gmp_prob_prime)
|
|||
|
||||
FETCH_GMP_ZVAL(gmpnum_a, gmpnumber_arg, temp_a);
|
||||
|
||||
RETVAL_LONG(mpz_probab_prime_p(gmpnum_a, reps));
|
||||
RETVAL_LONG(mpz_probab_prime_p(gmpnum_a, (int)reps));
|
||||
FREE_GMP_TEMP(temp_a);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1965,6 +1965,10 @@ ZEND_FUNCTION(gmp_setbit)
|
|||
php_error_docref(NULL, E_WARNING, "Index must be greater than or equal to zero");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (index / GMP_NUMB_BITS >= INT_MAX ) {
|
||||
php_error_docref(NULL, E_WARNING, "Index must be less than %ld * %ld", INT_MAX, GMP_NUMB_BITS);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
gmpnum_a = GET_GMP_FROM_ZVAL(a_arg);
|
||||
|
||||
|
|
26
ext/gmp/tests/gmp_setbit_long.phpt
Normal file
26
ext/gmp/tests/gmp_setbit_long.phpt
Normal file
|
@ -0,0 +1,26 @@
|
|||
--TEST--
|
||||
gmp_setbit() with large index
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("gmp")) print "skip"; ?>
|
||||
<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
|
||||
<?php if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$n = gmp_init("227200");
|
||||
for($a = 1<<30; $a > 0 && $a < 0x8000000000; $a <<= 2) {
|
||||
$i = $a - 1;
|
||||
printf("%X\n", $i);
|
||||
gmp_setbit($n, $i, 1);
|
||||
}
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
3FFFFFFF
|
||||
FFFFFFFF
|
||||
3FFFFFFFF
|
||||
FFFFFFFFF
|
||||
3FFFFFFFFF
|
||||
|
||||
Warning: gmp_setbit(): Index must be less than %d * %d in %s/gmp_setbit_long.php on line %d
|
||||
Done
|
Loading…
Add table
Add a link
Reference in a new issue