Skip to content

Commit ab4f120

Browse files
committed
Merge branch 'PHP-5.6'
Conflicts: NEWS ext/opcache/Optimizer/pass1_5.c
2 parents 3ad9ff1 + 3a660bf commit ab4f120

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

ext/phar/phar_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@
124124
#define TAR_SYMLINK '2'
125125
#define TAR_DIR '5'
126126
#define TAR_NEW '8'
127+
#define TAR_GLOBAL_HDR 'g'
128+
#define TAR_FILE_HDR 'x'
127129

128130
#define PHAR_MUNG_PHP_SELF (1<<0)
129131
#define PHAR_MUNG_REQUEST_URI (1<<1)

ext/phar/tar.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
255255
size = entry.uncompressed_filesize = entry.compressed_filesize =
256256
phar_tar_number(hdr->size, sizeof(hdr->size));
257257

258+
/* skip global/file headers (pax) */
259+
if (!old && (hdr->typeflag == TAR_GLOBAL_HDR || hdr->typeflag == TAR_FILE_HDR)) {
260+
size = (size+511)&~511;
261+
goto next;
262+
}
263+
258264
if (((!old && hdr->prefix[0] == 0) || old) && strlen(hdr->name) == sizeof(".phar/signature.bin")-1 && !strncmp(hdr->name, ".phar/signature.bin", sizeof(".phar/signature.bin")-1)) {
259265
zend_off_t curloc;
260266

@@ -555,6 +561,7 @@ int phar_parse_tarfile(php_stream* fp, char *fname, int fname_len, char *alias,
555561
size = (size+511)&~511;
556562

557563
if (((hdr->typeflag == '\0') || (hdr->typeflag == TAR_FILE)) && size > 0) {
564+
next:
558565
/* this is not good enough - seek succeeds even on truncated tars */
559566
php_stream_seek(fp, size, SEEK_CUR);
560567
if ((uint)php_stream_tell(fp) > totalsize) {

ext/phar/tests/tar/bug64343.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #64343 (phar cannot open tars with pax headers)
3+
--SKIPIF--
4+
<?php if (!extension_loaded("phar")) die("skip"); ?>
5+
--FILE--
6+
<?php
7+
8+
echo "Test\n";
9+
10+
$phar = new PharData(__DIR__."/files/bug64343.tar");
11+
12+
?>
13+
===DONE===
14+
--EXPECT--
15+
Test
16+
===DONE===

ext/phar/tests/tar/files/bug64343.tar

10 KB
Binary file not shown.

0 commit comments

Comments
 (0)