php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58202 Third-party zips fail entry interrogation
Submitted: 2008-05-24 22:37 UTC Modified: 2008-05-29 13:35 UTC
From: sfox@php.net Assigned: cellog (profile)
Status: Closed Package: phar (PECL)
PHP Version: 5_3 CVS-2008-05-24 (dev) OS: win32
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sfox@php.net
New email:
PHP Version: OS:

 

 [2008-05-24 22:37 UTC] sfox@php.net
Description:
------------
Sounds like a tabloid leader, but...

Basically you can't work with entry file contents from a third-party zip archive at present, at all. Not only can you not var_dump(file_get_contents()), it's also not possible to convert a third-party zip archive to executable for the same reason - 'internal corruption' is reported in both cases. It seems that entry contents aren't being copied across in phar_open_entry_fp() when it comes to zip archives.

Reproduce code:
---------------
<?php
/* adapted version of tests/zip/unixzip.phpt */

$a = new PharData(dirname(__FILE__) . '/files/zip.zip');

foreach ($a as $b) {
	if ($b->isDir()) {
		echo "dir " . $b->getPathName() . "\n";
	} else {
		echo $b->getPathName() . "\n";
		echo file_get_contents($b) . "\n";
	}
}

if (isset($a['notempty/hi.txt'])) {
	echo $a['notempty/hi.txt']->getPathName() . "\n";
}

?>

Expected result:
----------------
dir phar://%szip.zip%cempty
phar://%szip.zip%chi.txt
hi there
dir phar://%szip.zip%cnotempty
phar://%szip.zip/notempty/hi.txt

Actual result:
--------------
dir phar://C:/sandbox/php5/ext/phar/tests/zip/files/zip.zip\empty
phar://C:/sandbox/php5/ext/phar/tests/zip/files/zip.zip\hi.txt

Warning: file_get_contents(phar://C:/sandbox/php5/ext/phar/tests/zip/files/zip.zip\hi.txt): failed to open stream: phar error: internal corruption of phar "C:/sandbox/php5/ext/phar/tests/zip/files/zip.zip" (crc32 mismatch on file "hi.txt") in C:\sandbox\php5\ext\phar\tests\zip\unixzip.php on line 8

dir phar://C:/sandbox/php5/ext/phar/tests/zip/files/zip.zip\notempty
phar://C:/sandbox/php5/ext/phar/tests/zip/files/zip.zip/notempty/hi.txt

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-29 13:35 UTC] greg at chiaraquartet dot net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 02:01:29 2024 UTC