Bug #74674 [NEW]: Problem of extracting an archive with symbolic links
| From: | gwenael dot pellen at arkeup dot com | Date: | Tue, 30 May 2017 14:34:41 +0000 |
| Subject: | Bug #74674 [NEW]: Problem of extracting an archive with symbolic links | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-209303@lists.php.net to get a copy of this message | ||
From: gwenael dot pellen at arkeup dot com
Operating system: Linux Ubuntu 16.04 LTS
PHP version: 7.1.5
Package: PHAR related
Bug Type: Bug
Bug description:Problem of extracting an archive with symbolic links
Description:
------------
$ php -v
PHP 7.1.5-1+deb.sury.org~xenial+2 (cli) (built: May 22 2017 12:48:42) (
NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.5-1+deb.sury.org~xenial+2, Copyright (c)
1999-2017, by Zend Technologies
Create my data
$ mkdir /tmp/php-bug/ && cd /tmp/php-bug/
$ mkdir -p source1/dir1
$ mkdir -p source1/dir2
$ mkdir source2
$ ln -s ../source1/dir1 source2/dir1
$ ln -s ../source1/dir2 source2/dir2
Create TAR archive
$ tar cvf source2.tar source2/
source2/
source2/dir1
source2/dir2
Show TAR archive
$ tar tvf source2.tar
drwxr-xr-x root/root 0 2017-05-30 14:00 source2/
lrwxrwxrwx root/root 0 2017-05-30 14:00 source2/dir1 ->
../source1/dir1
lrwxrwxrwx root/root 0 2017-05-30 14:00 source2/dir2 ->
../source1/dir2
Create PHP script to extract this archive.
$ cat > extract.php <<EOT
<?php
\$path = getcwd();
echo \$path, "\n";
\$phar = new PharData('source2.tar');
\$phar->extractTo(\$path,null,true);
EOT
Launch PHP script
$ php extract.php
/tmp/php-bug
PHP Warning: PharData::extractTo(/tmp/php-bug/source2/dir1): failed to
open stream: Is a directory in /tmp/php-bug/extract.php on line 5
PHP Fatal error: Uncaught PharException: Extraction from phar
"/tmp/php-bug/source2.tar" failed: Cannot extract "source2/dir1", could
not open for writing "/tmp/php-bug/source2/dir1" in
/tmp/php-bug/extract.php:5
Stack trace:
#0 /tmp/php-bug/extract.php(5): PharData->extractTo('/tmp/php-bug',
NULL, true)
#1 {main}
thrown in /tmp/php-bug/extract.php on line 5
Test script:
---------------
<?php
$path = getcwd();
echo $path, "\n";
$phar = new PharData('source2.tar');
$phar->extractTo(\$path,null,true);
Expected result:
----------------
$ php extract.php
$
Actual result:
--------------
$ php extract.php
/tmp/php-bug
PHP Warning: PharData::extractTo(/tmp/php-bug/source2/dir1): failed to
open stream: Is a directory in /tmp/php-bug/extract.php on line 5
PHP Fatal error: Uncaught PharException: Extraction from phar
"/tmp/php-bug/source2.tar" failed: Cannot extract "source2/dir1", could
not open for writing "/tmp/php-bug/source2/dir1" in
/tmp/php-bug/extract.php:5
Stack trace:
#0 /tmp/php-bug/extract.php(5): PharData->extractTo('/tmp/php-bug',
NULL, true)
#1 {main}
thrown in /tmp/php-bug/extract.php on line 5
--
Edit bug report at https://bugs.php.net/bug.php?id=74674&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74674&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74674&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74674&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74674&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74674&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74674&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74674&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74674&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74674&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74674&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74674&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74674&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74674&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74674&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74674&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74674&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74674&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74674&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74674&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74674&r=mysqlcfg