Edit report at http://bugs.php.net/bug.php?id=49072&edit=1
ID: 49072 Updated by: paj...@php.net Reported by: TorokAlpar at Gmail dot com Summary: feof never returns true for damaged file in zip -Status: Closed +Status: Assigned Type: Bug Package: Zip Related Operating System: Windows Xp, Linux PHP Version: 5.3.0 Assigned To: cataphract Block user comment: N Private report: N New Comment: Test fails here: 001+ 001- Warning: fread(): Zip stream error: CRC error in %s on line %d Previous Comments: ------------------------------------------------------------------------ [2011-02-01 15:44:31] cataphr...@php.net Automatic comment from SVN on behalf of cataphract Revision: http://svn.php.net/viewvc/?view=revision&revision=307917 Log: - Fixed bug #49072 (feof never returns true for damaged file in zip). ------------------------------------------------------------------------ [2011-02-01 15:43:54] cataphr...@php.net Automatic comment from SVN on behalf of cataphract Revision: http://svn.php.net/viewvc/?view=revision&revision=307916 Log: - Fixed bug #49072 (feof never returns true for damaged file in zip). ------------------------------------------------------------------------ [2011-02-01 13:22:09] rquadl...@php.net Unassigned from me as I don't have karma. ------------------------------------------------------------------------ [2011-02-01 13:20:07] rquadl...@php.net The following patch has been added/updated: Patch Name: zip_stream_errors_reported.patch Revision: 1296562807 URL: http://bugs.php.net/patch-display.php?bug=49072&patch=zip_stream_errors_reported.patch&revision=1296562807 ------------------------------------------------------------------------ [2011-02-01 13:19:29] rquadl...@php.net The test http://svn.php.net/viewvc/php/php-src/trunk/ext/zip/tests/bug49072.phpt is currently failing. >From what I can tell, the reason for the failure is that the when processing (http://svn.php.net/viewvc/php/php-src/trunk/ext/zip/zip_stream.c?view=annotate#l31), the return type from zip_fread (line 37) is cast to size_t. This is, at the most basic, an unsigned type. So, when comparing (n < 0), this will always be false. And so any errors recording during the zip_fread() call will fail to be passed on. Removing the casting and having n as type int, allows the test to pass and the appropriate error is generated. Patch attached. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=49072 -- Edit this bug report at http://bugs.php.net/bug.php?id=49072&edit=1