php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39506 Archive corrupt with ZipArchive::addFile method
Submitted: 2006-11-13 23:22 UTC Modified: 2011-08-19 12:24 UTC
From: hscheidegger at zumbach dot ch Assigned: pajoye (profile)
Status: Closed Package: Zip Related
PHP Version: 5.2.0 OS: Windows XP
Private report: No CVE-ID: None
 [2006-11-13 23:22 UTC] hscheidegger at zumbach dot ch
Description:
------------
We use PHP 5.2 on Windows XP and Server 2003, not the CGI version.
We are running Apache 2 with php as module and php_zip.dll as extension declared in php.ini.
The following script produces a corrupt zip archive, depending the content of 'TestDoc1.txt':

<?php
$zip = new ZipArchive;
$res = $zip->open( 'test.zip', ZipArchive::CREATE );
if ($res === TRUE) {
   $zip->addFile( 'TestDoc1.txt', 'entryname1.txt' );
   $zip->close();
   echo 'ok';
} else {
   echo 'failed';
  }
?>

Reproduce code:
---------------
zip archive ok with TestDoc1.txt:
=================================
<body bgcolor="#CED5E5">
<br>

</body>
This is some text, we have to fill the file with nonsense.

zip archive corrupt with TestDoc1.txt:
======================================
<body bgcolor="#CED5E5">
<br>
x
</body>
This is some text, we have to fill the file with nonsense.




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-14 09:33 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-11-14 09:53 UTC] hscheidegger at zumbach dot ch
We have the same behaviour with the proposed CVS snapshot.
Do you need additional information?
 [2006-11-14 14:37 UTC] pajoye@php.net
Can you try your script using CLI?
 [2006-11-14 19:10 UTC] hscheidegger at zumbach dot ch
Yes I did and it works without error.
Now, how to get work the .dll version with Apache 2.2.3 on Windows XP?
 [2006-11-15 16:26 UTC] pajoye@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

I just commited a fix, it should fix it for all other SAPI (it works in CLI/CGI/Embed).
 [2006-11-15 18:00 UTC] hscheidegger at zumbach dot ch
Unfortunately there is still the same problem.
I'm using Apache2.2.3 and the related versions of php5apache2.dll and php5apache2_filter.dll;
Does this matter?
 [2006-11-15 19:18 UTC] pajoye@php.net
The snaps have not been yet updated. Please wait the _next_ one and try again :)
 [2006-11-16 13:13 UTC] hscheidegger at zumbach dot ch
The 'addFile()' method is now working in our environment.
Thanks for your help,
Regards, H-P Scheidegger
 [2006-11-17 18:42 UTC] pajoye@php.net
For the record here, it was not an addFile problem but the binary mode being ignored by the windows API. It is now forced  to binary using a lower level function.
 [2011-08-19 09:48 UTC] claudio dot baratti at gmail dot com
Sorry, I have the same problem with php version 5.2.8 and apache 2.2.11 on platform winxp. I cannot upgrade to 5.3 version. In this version whould I still have the problem? or it's has been fixed?
Claudio
 [2011-08-19 10:01 UTC] pajoye@php.net
PHP 5.2 is not supported anymore. I don't remember when was 5.2.8 released. Pls 
compare the release date with the date of this commit, that should give you the 
answer.
 [2011-08-19 11:34 UTC] claudio dot baratti at gmail dot com
5.2.8. has been released on 08 December 2008, so in theory I shouldn't have this problem.
 [2011-08-19 11:37 UTC] pajoye@php.net
Open a new bug with a reproduce script and with the data you use to reproduce your 
problem. Please keep it small and with only the zip related information.
 [2011-08-19 12:11 UTC] claudio dot baratti at amps-llc dot com
hello, the problem was reported on https://bugs.php.net/bug.php?id=46985, so i resolved it to download php_zip.dll of 5.2.6 php version. Thanks
 [2011-08-19 12:24 UTC] pajoye@php.net
It is not resolved.

Downloading a previous version and it works mean that the bug was reintroduced 
later.

Please, (oh please!) try using a recent version. You do not have to install php to 
try it, simply download the latest version, uncompress it somewhere and try your 
code in the console.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC