|  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
 [2007-11-03 22:38 UTC] markengland2000 at yahoo dot com
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:

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:
$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");


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).


Add a Patch

Pull Requests

Add a Pull Request


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:
 [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
 [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

In case this was a 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-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 12:01:26 2023 UTC