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.
2 parents 1a5128f + ef08bce commit 9644ba6Copy full SHA for 9644ba6
ext/standard/pack.c
@@ -366,7 +366,7 @@ PHP_FUNCTION(pack)
366
switch (code) {
367
case 'h':
368
case 'H':
369
- INC_OUTPUTPOS((arg + (arg % 2)) / 2,1) /* 4 bit per arg */
+ INC_OUTPUTPOS((arg / 2) + (arg % 2),1) /* 4 bit per arg */
370
break;
371
372
case 'a':
ext/standard/tests/strings/gh18976.phpt
@@ -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