1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3'

This commit is contained in:
David Carlier
2024-09-11 21:16:26 +01:00
2 changed files with 32 additions and 0 deletions

View File

@@ -977,6 +977,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;

View 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