Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Zend/tests/zend_ini/zend_ini_parse_uquantity_overflow.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ $tests = [
'No overflow 007' => ' -1',
'No overflow 008' => '-1 ',
'No overflow 009' => ' -1 ',
'Subject overflow 001' => base_convert(str_repeat('1', PHP_INT_SIZE*8+1), 2, 10),
'Subject overflow 002' => '-'.base_convert(str_repeat('1', PHP_INT_SIZE*8+1), 2, 10),
'Subject overflow 001' => PHP_INT_MAX.'0',
'Subject overflow 002' => PHP_INT_MIN.'0',
'Subject overflow 003' => strval(PHP_INT_MIN),
'Subject overflow 004' => '-2',
'Subject overflow 005' => '-1K',
Expand Down
1 change: 1 addition & 0 deletions ext/standard/math.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ PHPAPI void _php_math_basetozval(zend_string *str, int base, zval *ret)
num = num * base + c;
break;
} else {
zend_error(E_NOTICE, "Input number exceeds maximum integer value, precision has been lost in conversion");
fnum = (double)num;
mode = 1;
}
Expand Down
10 changes: 10 additions & 0 deletions ext/standard/tests/math/base_convert_overflow.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--TEST--
Test base_convert() - overflow test
--FILE--
<?php
var_dump(base_convert('fffffffffffffffff', 16, 15));
?>
--EXPECTF--

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
string(18) "2ee03c32ad644bd1e1"
2 changes: 2 additions & 0 deletions ext/standard/tests/math/bindec_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ int(129)
int(455)
int(224)
int(2147483647)

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(2147483648)

Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
Expand Down
8 changes: 7 additions & 1 deletion ext/standard/tests/math/bindec_basiclong_64bit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ foreach ($binLongStrs as $strVal) {
}

?>
--EXPECT--
--EXPECTF--
--- testing: 0111111111111111111111111111111111111111111111111111111111111111 ---
int(9223372036854775807)
--- testing: 1111111111111111111111111111111111111111111111111111111111111111 ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(1.8446744073709552E+19)
--- testing: 01111111111111111111111111111111 ---
int(2147483647)
--- testing: 11111111111111111111111111111111 ---
int(4294967295)
--- testing: 01111111111111111111111111111111111111111111111111111111111111111 ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(1.8446744073709552E+19)
--- testing: 11111111111111111111111111111111111111111111111111111111111111111 ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(3.6893488147419103E+19)
--- testing: 011111111111111111111111111111111 ---
int(4294967295)
Expand Down
12 changes: 8 additions & 4 deletions ext/standard/tests/math/hexdec.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var_dump(hexdec("12345"));
var_dump(hexdec("q12345"));
var_dump(hexdec("12345+?!"));
var_dump(hexdec("12345q"));
var_dump((float)hexdec("1234500001"));
var_dump((float)hexdec("17fffffff"));
var_dump(hexdec("12345678901234567"));
var_dump(hexdec("17fffffffffffffff"));

?>
--EXPECTF--
Expand All @@ -26,5 +26,9 @@ int(74565)

Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
int(74565)
float(78187069441)
float(6442450943)

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(2.0988295476557332E+19)

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(2.7670116110564327E+19)
6 changes: 6 additions & 0 deletions ext/standard/tests/math/hexdec_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ for ($i = 0; $i < count($values); $i++) {
--EXPECTF--
int(18433668)
int(126895953)

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(142929835591)

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(142929835592)
int(1194684)
int(7904751)
int(2147483647)

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(2147483648)

Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
Expand Down
8 changes: 7 additions & 1 deletion ext/standard/tests/math/hexdec_basiclong_64bit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ foreach ($hexLongStrs as $strVal) {
}

?>
--EXPECT--
--EXPECTF--
--- testing: 7fffffffffffffff ---
int(9223372036854775807)
--- testing: ffffffffffffffff ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(1.8446744073709552E+19)
--- testing: 7fffffff ---
int(2147483647)
--- testing: ffffffff ---
int(4294967295)
--- testing: 7ffffffffffffffff ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(1.4757395258967641E+20)
--- testing: ffffffffffffffffff ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(4.722366482869645E+21)
--- testing: 7ffffffff ---
int(34359738367)
Expand Down
8 changes: 8 additions & 0 deletions ext/standard/tests/math/hexdec_variation1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ Deprecated: Invalid characters passed for attempted conversion, these have been
int(9029)

-- Iteration 5 --

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(285960729237)

-- Iteration 6 --

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(285960729238)

-- Iteration 7 --
Expand All @@ -102,10 +106,14 @@ Deprecated: Invalid characters passed for attempted conversion, these have been
int(261)

-- Iteration 9 --

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(20015998341120)

-- Iteration 10 --

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d

Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
float(1250999896553)

Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/math/octdec_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ int(5349)
int(342391)
int(375)
int(2147483647)

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(2147483648)

Deprecated: Invalid characters passed for attempted conversion, these have been ignored in %s on line %d
Expand Down
8 changes: 7 additions & 1 deletion ext/standard/tests/math/octdec_basiclong_64bit.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,24 @@ foreach ($octLongStrs as $strVal) {
}

?>
--EXPECT--
--EXPECTF--
--- testing: 777777777777777777777 ---
int(9223372036854775807)
--- testing: 1777777777777777777777 ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(1.8446744073709552E+19)
--- testing: 17777777777 ---
int(2147483647)
--- testing: 37777777777 ---
int(4294967295)
--- testing: 377777777777777777777777 ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(2.3611832414348226E+21)
--- testing: 17777777777777777777777777 ---

Notice: Input number exceeds maximum integer value, precision has been lost in conversion in %s on line %d
float(7.555786372591432E+22)
--- testing: 377777777777 ---
int(34359738367)
Expand Down
Loading