php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57898 Modifying zip file results in corruption
Submitted: 2007-11-03 22:38 UTC Modified: 2009-07-20 15:22 UTC
From: markengland2000 at yahoo dot com Assigned: pajoye (profile)
Status: Closed Package: zip (PECL)
PHP Version: 5.2.1 OS: CentOS 4.5 / XP / Vista x64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: markengland2000 at yahoo dot com
New email:
PHP Version: OS:

 

 [2007-11-03 22:38 UTC] markengland2000 at yahoo dot com
Description:
------------
When using zip pecl to modify any Nokia S40 theme file (which have a .nth extension, but are actually zip archives), that's been created with the official Nokia S40 Theme Studio (v2.2), the resulting archive becomes corrupt. The contents of the archive can be extracted, but cannot be deleted. Nokia theme studio is also unable to open the archive unless I rebuild the zip by extracting all the files; manually creating a new zip file with either the zip pecl or windows explorer; and re-add all files.

This problem only occurs if the original nth theme file is saved with Nokia theme studio (of which the vast majority are) and modified with the zip pecl (note: there are no problems if modified with winzip or winrar). 

When modifying an nth file *created* with zip pecl, explorer, winrar or winzip, the archive will not become corrupt. I have included an example of this (see: themefile-rebuildfromcorrupt-ok.nth - I extracted files from corrupt folder and created this using win explorer) along with corrupted archives within the following zip: http://markw.fireflyinternet.com/nkthemefiles.zip

I've tried modifying a theme studio generated archive (theme) using zip pecl on a Linux CentOS 4.5 installation and my Vista x64 desktop (both latest PECL and PHP 5.2.3). In both cases, the resulting archive becomes corrupt (tested on XP and Vista). If opening in theme studio, I get the error, "Invalid entry size (expected 2806841352 but got 19670 bytes)".

Reproduce code:
---------------
error_reporting(E_ALL);
$zip = new ZipArchive();
$filename = "themefile-unmodified-ok.nth";

if ($zip->open($filename) !== true) {
	exit "cannot open <$filename>\n";
} else {
	echo "file <$filename> OK\n";
}
$zip->addFromString("test.txt", "0123456789");

var_dump($zip->close());
var_dump($zip);

Expected result:
----------------
themefile-unmodified-ok.nth should not become corrupt. After executing the code, rename and open the nth file as a zip archive, then try deleting a file within it. A "corrupt" error will be returned. Note: themefile-unmodified-ok.nth is created with Nokia S40 Theme Studio.

Actual result:
--------------
themefile-unmodified-ok.nth becomes corrupt (see themefile-modifiedwithpecl-corrupt.nth).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-11-03 22:49 UTC] markengland2000 at yahoo dot com
I provided an incorrect URL. Here's the correct one:

http://markw.fireflyinternet.co.uk/nkthemefiles.zip
 [2007-11-04 06:56 UTC] pierre dot php at gmail dot com
Thanks for the detailed report and test cases. I don't have the time now to investigate but I will keep you informed about a possible solution here. However do not expect a reply in the next 2 weeks.
 [2007-12-02 12:08 UTC] pierre dot php at gmail dot com
Can you try it using 5.2.5 please? I can't reproduce it anymore and it looks like a bug we already fixed (was related to the same kind of zip archive used by openoffice, a special bit was used in the entry info).
 [2008-05-20 19:59 UTC] pierre dot php at gmail dot com
Please try using this snap http://blog.thepimp.net/misc/zip-1.10.0.tgz
 [2009-07-20 15:22 UTC] pierre dot php at gmail dot com
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Dec 02 23:03:35 2021 UTC