|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-11-10 02:52 UTC] pierre dot php at gmail dot com
[2007-11-10 03:13 UTC] groepaz at gmx dot net
[2007-11-13 11:09 UTC] matt at signpostservices dot co dot uk
[2007-12-02 12:12 UTC] pierre dot php at gmail dot com
[2008-05-20 19:57 UTC] pierre dot php at gmail dot com
[2008-05-20 20:00 UTC] pierre dot php at gmail dot com
[2013-02-18 00:35 UTC] pecl-dev at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
Description: ------------ my app is supposed to scan directories for zip files, and put their contents into a database. since i am dealing with thousends of files there, it is likely that every now and then one of these archives is corrupted. it seems that under certain circumstances these archives will open and list their content fine, but extracting data from them fails. this is what unzip has to say about one of these archives: $ unzip -t ./test/arch/zip/c64demo.zip Archive: ./test/arch/zip/c64demo.zip error [./test/arch/zip/c64demo.zip]: missing 1 bytes in zipfile (attempting to process anyway) error [./test/arch/zip/c64demo.zip]: attempt to seek before beginning of zipfile (please check that you have transferred or created the zipfile in the appropriate BINARY mode and that you have compiled UnZip properly) (attempting to re-compensate) testing: 64DEMO.PAS OK testing: MOB64.PAS bad CRC 893e928b (should be 3a92f29b) file #3: bad zipfile offset (local header sig): 3038 (attempting to re-compensate) testing: NINJA3.PIC OK testing: ZX-FLORD.PIC OK testing: ROZNE.MOB OK testing: SWISS.MBF OK testing: TFIGHT.MOB OK testing: LEONARDO.FNB OK testing: NOTE-1.FNT OK testing: MYLOGOV2.GFX OK At least one error was detected in ./test/arch/zip/c64demo.zip. and zip says: $ zip -T ./test/arch/zip/c64demo.zip zip warning: local header not found for NINJA3.PIC with this archive, extracting the "MOB64.PAS" file will cause the extension to hang (no matter if i am using getStream/fread or getFromName). the archive: http://hitmen.c02.at/temp/c64demo.zip Reproduce code: --------------- shortened excerpt from my code. i dont think this is relevant, it works fine with thousends of files. $za = new ZipArchive(); $res =$za->open($zipname); if ($res === TRUE) { $finfo=$za->statName($filename); $file_size=$finfo['size']; if($file_size>$MAX_PACKED_SCAN_FILELENGTH) { $contents=false; } else { if($file_size>0) { // it hangs right here $contents=$za->getFromName($filename); echo "<br>ZIP contents size:".strlen($contents);flush();ob_flush(); if(strlen($contents)!=$file_size) { warning(modestr(1)." zip_readfile recorded data does not match unpacked size :".$zipname.":".$filename); } } else { $contents=false; warning(modestr(1)." zip_readfile could not open stream from zero length file ".$zipname.":".$filename); } } $za->close(); return $contents; } else { warning(modestr(1)." zip_readfile could not read from ".$zipname.":".$filename); return false; }