File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed 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 (ZEND_LONG_INT_OVFL ((zend_long )size * 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
+ --INI--
4
+ memory_limit=-1
5
+ --FILE--
6
+ <?php
7
+ try {
8
+ unpack ('h2147483647 ' , str_repeat ('X ' , 2 **31 + 10 ));
9
+ } catch (\ValueError $ e ) {
10
+ echo $ e ->getMessage () . PHP_EOL ;
11
+ }
12
+
13
+ try {
14
+ unpack ('H2147483647 ' , str_repeat ('X ' , 2 **31 + 10 ));
15
+ } catch (\ValueError $ e ) {
16
+ echo $ e ->getMessage ();
17
+ }
18
+ ?>
19
+ --EXPECTF--
20
+ unpack(): Argument #1 ($format) repeater must be less than or equal to %d
21
+ 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