Skip to content

Commit 3477499

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix regression introduced by fixing bug 81726
2 parents 8b11525 + 432bf19 commit 3477499

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ext/phar/phar.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,7 +1635,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
16351635
const char zip_magic[] = "PK\x03\x04";
16361636
const char gz_magic[] = "\x1f\x8b\x08";
16371637
const char bz_magic[] = "BZh";
1638-
char *pos;
1638+
char *pos, test = '\0';
16391639
int recursion_count = 3; // arbitrary limit to avoid too deep or even infinite recursion
16401640
const int window_size = 1024;
16411641
char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */
@@ -1664,7 +1664,8 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
16641664
MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated entry)")
16651665
}
16661666

1667-
if (recursion_count) {
1667+
if (!test && recursion_count) {
1668+
test = '\1';
16681669
pos = buffer+tokenlen;
16691670
if (!memcmp(pos, gz_magic, 3)) {
16701671
char err = 0;
@@ -1724,6 +1725,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
17241725
compression = PHAR_FILE_COMPRESSED_GZ;
17251726

17261727
/* now, start over */
1728+
test = '\0';
17271729
if (!--recursion_count) {
17281730
MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\"");
17291731
break;
@@ -1765,6 +1767,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
17651767
compression = PHAR_FILE_COMPRESSED_BZ2;
17661768

17671769
/* now, start over */
1770+
test = '\0';
17681771
if (!--recursion_count) {
17691772
MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\"");
17701773
break;

0 commit comments

Comments
 (0)