Skip to content

Commit e148fff

Browse files
committed
Merge branch 'PHP-5.6'
* PHP-5.6: BFN fix bug #67761
2 parents 7409053 + 64d9c98 commit e148fff

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

ext/phar/tar.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ int phar_is_tar(char *buf, char *fname) /* {{{ */
102102
tar_header *header = (tar_header *) buf;
103103
php_uint32 checksum = phar_tar_number(header->checksum, sizeof(header->checksum));
104104
php_uint32 ret;
105-
char save[sizeof(header->checksum)];
105+
char save[sizeof(header->checksum)], *bname;
106106

107107
/* assume that the first filename in a tar won't begin with <?php */
108108
if (!strncmp(buf, "<?php", sizeof("<?php")-1)) {
@@ -113,7 +113,10 @@ int phar_is_tar(char *buf, char *fname) /* {{{ */
113113
memset(header->checksum, ' ', sizeof(header->checksum));
114114
ret = (checksum == phar_tar_checksum(buf, 512));
115115
memcpy(header->checksum, save, sizeof(header->checksum));
116-
if (!ret && strstr(fname, ".tar")) {
116+
if ((bname = strrchr(fname, PHP_DIR_SEPARATOR))) {
117+
fname = bname;
118+
}
119+
if (!ret && (bname = strstr(fname, ".tar")) && (bname[4] == '\0' || bname[4] == '.')) {
117120
/* probably a corrupted tar - so we will pretend it is one */
118121
return 1;
119122
}

ext/phar/tests/tar/bug67761.phpt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Bug #67761 (Phar::mapPhar fails for Phars inside a path containing ".tar")
3+
--SKIPIF--
4+
<?php extension_loaded("phar") or die("SKIP need ext/phar suppport"); ?>
5+
--FILE--
6+
<?php
7+
8+
echo "Test\n";
9+
10+
include __DIR__."/files/bug67761.tar/bug67761.phar";
11+
12+
?>
13+
14+
===DONE===
15+
--EXPECT--
16+
Test
17+
#!/usr/bin/env php
18+
Test
19+
===DONE===
Binary file not shown.

0 commit comments

Comments
 (0)