Skip to content

Commit 847c5a5

Browse files
committed
apply suggestion
1 parent b68c68e commit 847c5a5

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

ext/standard/pack.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff 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':
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
--TEST--
22
GH-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

0 commit comments

Comments
 (0)