Bug #54485 [NEW]: extractTo reports success even in case of write error
| From: | arno at renevier dot net | Date: | Thu, 07 Apr 2011 13:02:39 +0000 |
| Subject: | Bug #54485 [NEW]: extractTo reports success even in case of write error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-159994@lists.php.net to get a copy of this message | ||
From:
Operating system: linux
PHP version: 5.3SVN-2011-04-07 (snap)
Package: Zip Related
Bug Type: Bug
Bug description:extractTo reports success even in case of write error
Description:
------------
Hi,
I've encountered the bug when trying to unzip a file into a full disk.
ZipArchive::extractTo reported true, but the extracted file had a 0 size.
It would be nice if extractTo had reported false, so I could have known
something was wrong.
I've experienced the bug with debian php 5.3.6-7 and with php build from
php5.3-201104071030.tar.bz2 with ./configure --enable-zip && make
May be php_zip_extract_file could return 0 if php_stream_write returns 0 in
the n=zip_fread loop
PS: this bug may be the same as #53893 but as I'm unsure, I prefer to open
a new one.
Test script:
---------------
function unzip ($file) {
$za = new \ZipArchive();
if ($za->open($file) === FALSE) {
throw new Exception ("invalid zip file " . $file);
}
if ($za->numFiles != 1) {
throw new Exception ("invalid zip file " . $file);
}
if (($archive = $za->getNameIndex(0)) === FALSE) {
throw new Exception ("invalid zip file " . $file);
}
if ($za->extractTo('target', $archive) === FALSE) {
throw new Exception ("could not extract archive " . $archive);
}
if ($za->close() === FALSE) {
throw new Exception ("could not extract archive " . $archive);
}
}
unzip('somefile.zip');
Expected result:
----------------
the script should throw an exception.
Actual result:
--------------
no exception is thrown.
--
Edit bug report at http://bugs.php.net/bug.php?id=54485&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=54485&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=54485&r=trysnapshot53
Try a snapshot (trunk): http://bugs.php.net/fix.php?id=54485&r=trysnapshottrunk
Fixed in SVN: http://bugs.php.net/fix.php?id=54485&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=54485&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=54485&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=54485&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=54485&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=54485&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=54485&r=support
Expected behavior: http://bugs.php.net/fix.php?id=54485&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=54485&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=54485&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=54485&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54485&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54485&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=54485&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=54485&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=54485&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=54485&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=54485&r=mysqlcfg