mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.2' into PHP-8.3
This commit is contained in:
@@ -979,6 +979,13 @@ PHP_FUNCTION(unpack)
|
||||
zend_string *buf;
|
||||
zend_long ipos, opos;
|
||||
|
||||
|
||||
if (size > INT_MAX / 2) {
|
||||
zend_string_release(real_name);
|
||||
zend_argument_value_error(1, "repeater must be less than or equal to %d", INT_MAX / 2);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
/* If size was given take minimum of len and size */
|
||||
if (size >= 0 && len > (size * 2)) {
|
||||
len = size * 2;
|
||||
|
||||
25
ext/standard/tests/strings/gh15613.phpt
Normal file
25
ext/standard/tests/strings/gh15613.phpt
Normal file
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
GH-15613 overflow on hex strings repeater value
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (PHP_INT_SIZE != 8) die("skip this test is for 64 bit platform only");
|
||||
?>
|
||||
--INI--
|
||||
memory_limit=-1
|
||||
--FILE--
|
||||
<?php
|
||||
try {
|
||||
unpack('h2147483647', str_repeat('X', 2**31 + 10));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
unpack('H2147483647', str_repeat('X', 2**31 + 10));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECTF--
|
||||
unpack(): Argument #1 ($format) repeater must be less than or equal to %d
|
||||
unpack(): Argument #1 ($format) repeater must be less than or equal to %d
|
||||
Reference in New Issue
Block a user