Skip to content

Commit 8ba8383

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix regression introduced by fixing bug 81726
2 parents 3579dda + 4552f62 commit 8ba8383

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
@@ -1626,7 +1626,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
16261626
const char zip_magic[] = "PK\x03\x04";
16271627
const char gz_magic[] = "\x1f\x8b\x08";
16281628
const char bz_magic[] = "BZh";
1629-
char *pos;
1629+
char *pos, test = '\0';
16301630
int recursion_count = 3; // arbitrary limit to avoid too deep or even infinite recursion
16311631
const int window_size = 1024;
16321632
char buffer[1024 + sizeof(token)]; /* a 1024 byte window + the size of the halt_compiler token (moving window) */
@@ -1655,7 +1655,8 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
16551655
MAPPHAR_ALLOC_FAIL("internal corruption of phar \"%s\" (truncated entry)")
16561656
}
16571657

1658-
if (recursion_count) {
1658+
if (!test && recursion_count) {
1659+
test = '\1';
16591660
pos = buffer+tokenlen;
16601661
if (!memcmp(pos, gz_magic, 3)) {
16611662
char err = 0;
@@ -1715,6 +1716,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
17151716
compression = PHAR_FILE_COMPRESSED_GZ;
17161717

17171718
/* now, start over */
1719+
test = '\0';
17181720
if (!--recursion_count) {
17191721
MAPPHAR_ALLOC_FAIL("unable to decompress gzipped phar archive \"%s\"");
17201722
break;
@@ -1756,6 +1758,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
17561758
compression = PHAR_FILE_COMPRESSED_BZ2;
17571759

17581760
/* now, start over */
1761+
test = '\0';
17591762
if (!--recursion_count) {
17601763
MAPPHAR_ALLOC_FAIL("unable to decompress bzipped phar archive \"%s\"");
17611764
break;

0 commit comments

Comments
 (0)