File tree Expand file tree Collapse file tree 2 files changed +10
-20
lines changed
Expand file tree Collapse file tree 2 files changed +10
-20
lines changed Original file line number Diff line number Diff line change @@ -388,13 +388,7 @@ PHP_FUNCTION(pack)
388388 switch ((int ) code ) {
389389 case 'h' :
390390 case 'H' :
391- if (arg == INT_MAX ) {
392- efree (formatcodes );
393- efree (formatargs );
394- zend_value_error ("Type %c: integer overflow in format string" , code );
395- RETURN_THROWS ();
396- }
397- INC_OUTPUTPOS ((arg + (arg % 2 )) / 2 ,1 ) /* 4 bit per arg */
391+ INC_OUTPUTPOS ((arg / 2 ) + (arg % 2 ),1 ) /* 4 bit per arg */
398392 break ;
399393
400394 case 'a' :
Original file line number Diff line number Diff line change 11--TEST--
22GH-18976 pack overflow wit h/H format
3+ --INI--
4+ memory_limit=-1
35--FILE--
46<?php
5- try {
6- pack ('h2147483647 ' , 1 );
7- } catch (ValueError $ e ) {
8- echo $ e ->getMessage (), PHP_EOL ;
9- }
10- try {
11- pack ('H2147483647 ' , 1 );
12- } catch (ValueError $ e ) {
13- echo $ e ->getMessage (), PHP_EOL ;
14- }
7+ pack ('h2147483647 ' , 1 );
8+ pack ('H2147483647 ' , 1 );
159?>
16- --EXPECT--
17- Type h: integer overflow in format string
18- Type H: integer overflow in format string
10+ --EXPECTF--
11+
12+ Warning: pack(): Type h: not enough characters in string in %s on line %d
13+
14+ Warning: pack(): Type H: not enough characters in string in %s on line %d
You can’t perform that action at this time.
0 commit comments