Bug #72412 [Opn->Ver]: PharData for archive containing "relative current directory" ( ./ )

From: Date: Tue, 08 Dec 2020 15:03:47 +0000
Subject: Bug #72412 [Opn->Ver]: PharData for archive containing "relative current directory" ( ./ )
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-230942@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72412&edit=1 ID: 72412 Updated by: cmb@php.net Reported by: raphael dot droz at gmail dot com Summary: PharData for archive containing "relative current directory" ( ./ ) -Status: Open +Status: Verified Type: Bug Package: PHAR related Operating System: Linux -PHP Version: 5.6.22 +PHP Version: 7.4 Block user comment: N Private report: N New Comment: This is broken due to the fix for bug #70019 (i.e. as of PHP 5.4.44, 5.5.28 and 5.6.12, respectively). After calling virtual_file_ex(), there is an additional check for new_state.cwd_length <= 1[1], whose purpose is not clear to me. If I remove that check, the tarball could be extracted if $overwrite was true; otherwise the extraction of . fails because the directory already exists. [1] <https://github.com/php/php-src/blob/php-7.4.13/ext/phar/phar_object.c#L4164-L4165> Previous Comments: ------------------------------------------------------------------------ [2016-06-15 13:24:01] raphael dot droz at gmail dot com Description: ------------ When creating a tar archive containing . Phar seems unable to extract it. Extracting ./file1 would work, but listing or extracting the whole archive does not seem possible and fail with a Fatal internal error. This is especially annoying if you don't know in advance the name of the file to extract: in such case the archive is simply unsuitable for Phar. As seen on IRC, it (july 14th), it does not affect every PHP version. Maybe related to bug #64884 since some symptoms seem common. Test script: --------------- mkdir -p test1; echo "This is a test file" > test1/file1; tar czf test1.tar.gz -C test1 . php -r '$p = new PharData("/tmp/test1.tar.gz"); $p->extractTo("test2");' cat test2/file1 Expected result: ---------------- This is a test file Actual result: -------------- Extraction from phar "/tmp/test1.tar.gz" failed: Cannot extract ".", internal error in Command line code on line 1 # Note that the "test1" directory is created, but empty ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72412&edit=1

« previous php.bugs (#230942) next »