File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ PHP NEWS
15
15
- SOAP:
16
16
. Fixed bug #62900 (Wrong namespace on xsd import error message). (nielsdos)
17
17
18
+ - Standard:
19
+ . Fixed bug GH-15613 (overflow on unpack call hex string repeater).
20
+ (David Carlier)
21
+
18
22
26 Sep 2024, PHP 8.2.24
19
23
20
24
- Core:
Original file line number Diff line number Diff line change @@ -979,6 +979,13 @@ PHP_FUNCTION(unpack)
979
979
zend_string * buf ;
980
980
zend_long ipos , opos ;
981
981
982
+
983
+ if (size > INT_MAX / 2 ) {
984
+ zend_string_release (real_name );
985
+ zend_argument_value_error (1 , "repeater must be less than or equal to %d" , INT_MAX / 2 );
986
+ RETURN_THROWS ();
987
+ }
988
+
982
989
/* If size was given take minimum of len and size */
983
990
if (size >= 0 && len > (size * 2 )) {
984
991
len = size * 2 ;
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-15613 overflow on hex strings repeater value
3
+ --SKIPIF--
4
+ <?php
5
+ if (PHP_INT_SIZE != 8 ) die ("skip this test is for 64 bit platform only " );
6
+ ?>
7
+ --INI--
8
+ memory_limit=-1
9
+ --FILE--
10
+ <?php
11
+ try {
12
+ unpack ('h2147483647 ' , str_repeat ('X ' , 2 **31 + 10 ));
13
+ } catch (\ValueError $ e ) {
14
+ echo $ e ->getMessage () . PHP_EOL ;
15
+ }
16
+
17
+ try {
18
+ unpack ('H2147483647 ' , str_repeat ('X ' , 2 **31 + 10 ));
19
+ } catch (\ValueError $ e ) {
20
+ echo $ e ->getMessage ();
21
+ }
22
+ ?>
23
+ --EXPECTF--
24
+ unpack(): Argument #1 ($format) repeater must be less than or equal to %d
25
+ unpack(): Argument #1 ($format) repeater must be less than or equal to %d
You can’t perform that action at this time.
0 commit comments