@@ -1635,7 +1635,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
1635
1635
const char zip_magic [] = "PK\x03\x04" ;
1636
1636
const char gz_magic [] = "\x1f\x8b\x08" ;
1637
1637
const char bz_magic [] = "BZh" ;
1638
- char * pos ;
1638
+ char * pos , test = '\0' ;
1639
1639
int recursion_count = 3 ; // arbitrary limit to avoid too deep or even infinite recursion
1640
1640
const int window_size = 1024 ;
1641
1641
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
1664
1664
MAPPHAR_ALLOC_FAIL ("internal corruption of phar \"%s\" (truncated entry)" )
1665
1665
}
1666
1666
1667
- if (recursion_count ) {
1667
+ if (!test && recursion_count ) {
1668
+ test = '\1' ;
1668
1669
pos = buffer + tokenlen ;
1669
1670
if (!memcmp (pos , gz_magic , 3 )) {
1670
1671
char err = 0 ;
@@ -1724,6 +1725,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
1724
1725
compression = PHAR_FILE_COMPRESSED_GZ ;
1725
1726
1726
1727
/* now, start over */
1728
+ test = '\0' ;
1727
1729
if (!-- recursion_count ) {
1728
1730
MAPPHAR_ALLOC_FAIL ("unable to decompress gzipped phar archive \"%s\"" );
1729
1731
break ;
@@ -1765,6 +1767,7 @@ static int phar_open_from_fp(php_stream* fp, char *fname, size_t fname_len, char
1765
1767
compression = PHAR_FILE_COMPRESSED_BZ2 ;
1766
1768
1767
1769
/* now, start over */
1770
+ test = '\0' ;
1768
1771
if (!-- recursion_count ) {
1769
1772
MAPPHAR_ALLOC_FAIL ("unable to decompress bzipped phar archive \"%s\"" );
1770
1773
break ;
0 commit comments