@@ -1626,7 +1626,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
1626
1626
const char zip_magic [] = "PK\x03\x04" ;
1627
1627
const char gz_magic [] = "\x1f\x8b\x08" ;
1628
1628
const char bz_magic [] = "BZh" ;
1629
- char * pos ;
1629
+ char * pos , test = '\0' ;
1630
1630
int recursion_count = 3 ; // arbitrary limit to avoid too deep or even infinite recursion
1631
1631
const int window_size = 1024 ;
1632
1632
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
1655
1655
MAPPHAR_ALLOC_FAIL ("internal corruption of phar \"%s\" (truncated entry)" )
1656
1656
}
1657
1657
1658
- if (recursion_count ) {
1658
+ if (!test && recursion_count ) {
1659
+ test = '\1' ;
1659
1660
pos = buffer + tokenlen ;
1660
1661
if (!memcmp (pos , gz_magic , 3 )) {
1661
1662
char err = 0 ;
@@ -1715,6 +1716,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
1715
1716
compression = PHAR_FILE_COMPRESSED_GZ ;
1716
1717
1717
1718
/* now, start over */
1719
+ test = '\0' ;
1718
1720
if (!-- recursion_count ) {
1719
1721
MAPPHAR_ALLOC_FAIL ("unable to decompress gzipped phar archive \"%s\"" );
1720
1722
break ;
@@ -1756,6 +1758,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
1756
1758
compression = PHAR_FILE_COMPRESSED_BZ2 ;
1757
1759
1758
1760
/* now, start over */
1761
+ test = '\0' ;
1759
1762
if (!-- recursion_count ) {
1760
1763
MAPPHAR_ALLOC_FAIL ("unable to decompress bzipped phar archive \"%s\"" );
1761
1764
break ;
0 commit comments