We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aee1d7f commit de4b9d1Copy full SHA for de4b9d1
ext/standard/pack.c
@@ -388,7 +388,7 @@ PHP_FUNCTION(pack)
388
switch ((int) code) {
389
case 'h':
390
case 'H':
391
- INC_OUTPUTPOS((arg + (arg % 2)) / 2,1) /* 4 bit per arg */
+ INC_OUTPUTPOS((arg / 2) + (arg % 2),1) /* 4 bit per arg */
392
break;
393
394
case 'a':
ext/standard/tests/strings/gh18976.phpt
@@ -0,0 +1,14 @@
1
+--TEST--
2
+GH-18976 (pack overflow wit 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