Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.5

Bug #17330 File_Archive create invalid zip file
Submitted: 2010-04-21 08:46 UTC
From: onjo Assigned:
Status: Open Package: File_Archive (version 1.5.4)
PHP Version: 5.2.10 OS: Solaris 8
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 17 + 40 = ?

 
 [2010-04-21 08:46 UTC] onjo (Masayuki Onjo)
Description: ------------ File_Archive create invalid file, it seems to be caused by file's mtime. There are no problems on i386 linux + PHP 5.2.13 + File_Archive 1.5.4. Test script: --------------- % diff php.ini-dist php.ini 1195a1196 > mbstring.internal_encoding = SJIS-WIN % touch -m -t 201004131354 0413.txt % touch -m -t 201004141354 0414.txt % cat >test.php <? require_once('File/Archive.php'); File_Archive::extract( File_Archive::read("0413.txt"), File_Archive::toArchive("./0413.zip", File_Archive::toFiles() )); File_Archive::extract( File_Archive::read("0414.txt"), File_Archive::toArchive("./0414.zip", File_Archive::toFiles() )); ?> % php -c php.ini test.php Expected result: ---------------- % zipinfo 0413.zip Archive: 0413.zip 116 bytes 1 file -rw---- 0.0 fat 0 b- defN 13-Apr-10 13:54 0413.txt 1 file, 0 bytes uncompressed, 2 bytes compressed: 0.0% % zipinfo 0414.zip Archive: 0414.zip 116 bytes 1 file -rw---- 0.0 fat 0 b- defN 14-Apr-10 13:54 0414.txt 1 file, 0 bytes uncompressed, 2 bytes compressed: 0.0% Actual result: -------------- % zipinfo 0413.zip Archive: 0413.zip 116 bytes 1 file -rw---- 0.0 fat 0 b- defN 13-Apr-10 29:36 0413.txt 1 file, 0 bytes uncompressed, 2 bytes compressed: 0.0% % zipinfo 0414.zip Archive: 0414.zip 114 bytes 1 file -rw---- 0.0 fat 134217728 b- defN 28-Jan-80 29:36 note: didn't find end-of-central-dir signature at end of central dir. 1 file, 134217728 bytes uncompressed, 0 bytes compressed: 100.0%

Comments

 [2011-11-10 21:49 UTC] marcj (MArc Schmidt)
I can confirm this bug on my machine: Linux xxx 2.6.26-2-amd64 #1 SMP Sun Jun 20 20:16:30 UTC 2010 x86_64 GNU/Linux cat /etc/debian_version 5.0.5 php -v PHP 5.2.6-1+lenny13 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 1 2011 16:01:01) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies The strange thing is, that it works on a other machine with equal software versions. Can't figure out, where the difference is. Did you find a solution already? What did you mean with it can be caused by file's mtime?
 [2011-11-11 19:06 UTC] onjo (Masayuki Onjo)
My fix is using pack() instead of preg_replace & eval (in File/Archive/Writer/Zip.php's getMTime()). It is because some specific $mtime bit-pattern break preg_replace and/or eval ... sorry, my memory has faded and I don't have environment. :-(