Skip to content

Commit 9644ba6

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 1a5128f + ef08bce commit 9644ba6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ext/standard/pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ PHP_FUNCTION(pack)
366366
switch (code) {
367367
case 'h':
368368
case 'H':
369-
INC_OUTPUTPOS((arg + (arg % 2)) / 2,1) /* 4 bit per arg */
369+
INC_OUTPUTPOS((arg / 2) + (arg % 2),1) /* 4 bit per arg */
370370
break;
371371

372372
case 'a':
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
GH-18976 (pack overflow with h/H format)
3+
--INI--
4+
memory_limit=-1
5+
--FILE--
6+
<?php
7+
pack('h2147483647', 1);
8+
pack('H2147483647', 1);
9+
?>
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)