Bug #54485 [Fbk->NoF]: extractTo reports success even in case of write error

From: Date: Mon, 18 Feb 2013 00:34:49 +0000
Subject: Bug #54485 [Fbk->NoF]: extractTo reports success even in case of write error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-176988@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54485&edit=1 ID: 54485 Updated by: php-bugs@lists.php.net Reported by: arno at renevier dot net Summary: extractTo reports success even in case of write error -Status: Feedback +Status: No Feedback Type: Bug Package: Zip Related Operating System: linux PHP Version: 5.3SVN-2011-04-07 (snap) Assigned To: pajoye New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Open". Thank you. Previous Comments: ------------------------------------------------------------------------ [2011-04-07 15:15:06] arno at renevier dot net > Is the error due to the zip archive or the destination directory (not writable, etc.)? As I told in the bug report, the bug appears when the destination directory is a full device (no space left). > Please provide a standalone reproduce case. the script I paste triggers the bug for any zip file named somefile.zip when target is directory on a full disk. Here are instructions to create a zip file: $ echo "something" > readme.txt $ zip readme.txt somefile.zip Here are the instructions to make target look like a full device (you may need root permissions at some point): $ dd if=/dev/zero of=file bs=4M count=1 $ mkdir target $ losetup /dev/loop0 file $ mkfs.ext3 /dev/loop0 $ mkdir target $ mount /dev/loop0 target $ cd target/ $ dd if=/dev/zero of=full bs=4M count=1 ------------------------------------------------------------------------ [2011-04-07 15:05:07] pajoye@php.net Please provide a standalone reproduce case. Is the error due to the zip archive or the destination directory (not writable, etc.)? ------------------------------------------------------------------------ [2011-04-07 15:02:38] arno at renevier dot net 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 this bug report at https://bugs.php.net/bug.php?id=54485&edit=1

« previous php.bugs (#176988) next »