File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -388,6 +388,12 @@ 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+ }
391397 INC_OUTPUTPOS ((arg + (arg % 2 )) / 2 ,1 ) /* 4 bit per arg */
392398 break ;
393399
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-18976 pack overflow wit h/H format
3+ --FILE--
4+ <?php
5+ try {
6+ pack ('h2147483647 ' );
7+ } catch (ValueError $ e ) {
8+ echo $ e ->getMessage (), PHP_EOL ;
9+ }
10+ try {
11+ pack ('H2147483647 ' );
12+ } catch (ValueError $ e ) {
13+ echo $ e ->getMessage (), PHP_EOL ;
14+ }
15+ ?>
16+ --EXPECT--
17+ Type h: integer overflow in format string
18+ Type H: integer overflow in format string
You can’t perform that action at this time.
0 commit comments