Skip to content

Commit d8c80af

Browse files
committed
Fixed bug #75075 (unpack with X* causes infinity loop)
1 parent 2def856 commit d8c80af

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ PHP NEWS
5353
. Fixed bug #75015 (Crash in recursive iterator destructors). (Julien)
5454

5555
- Standard:
56+
. Fixed bug #75075 (unpack with X* causes infinity loop). (Laruence)
5657
. Fixed bug #74103 (heap-use-after-free when unserializing invalid array
5758
size). (Nikita)
5859
. Fixed bug #75054 (A Denial of Service Vulnerability was found when

ext/standard/pack.c

+4
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,10 @@ PHP_FUNCTION(unpack)
782782
/* Never use any input */
783783
case 'X':
784784
size = -1;
785+
if (arg < 0) {
786+
php_error_docref(NULL, E_WARNING, "Type %c: '*' ignored", type);
787+
arg = 1;
788+
}
785789
break;
786790

787791
case '@':
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #75075 (unpack with X* causes infinity loop)
3+
--FILE--
4+
<?php
5+
var_dump(unpack("X*", ""));
6+
?>
7+
--EXPECTF--
8+
Warning: unpack(): Type X: '*' ignored in %sbug75075.php on line %d
9+
array(0) {
10+
}

0 commit comments

Comments
 (0)