[Bug 406303] [NEW] Compiled zip support in PHP 5.2.4 64bit can't open archives with large number of files.

ScHRiLL gorjan at orion.com.mk
Wed Jul 29 11:52:57 BST 2009


Public bug reported:

Binary package hint: php5

There is a problem with the compiled zip support in PHP5 package ver. 5.2.4 that comes with Ubuntu 8.04 LTS 64 bit. When php opens archives with large number of files it throws an error. This is a confirmed php5 bug and it effects all 64bit operating system that have php5 ver. 5.2.4 and because this is an LTS version it should be patched. 
- To check if this affecting you try this script
Reproduce code:
---------------
#!/bin/sh
rm -rf test1 test2 test1.zip test2.zip
mkdir test1 test2
cd test1
php -r 'for ($i = 1; $i < 800; $i++) system("touch test$i.txt");'
cd ../
zip -r test1.zip test1 > /dev/null
php -r '$zip = new ZipArchive(); var_dump($zip->open("test1.zip"));
var_dump($zip->numFiles);'

cd test2
php -r 'for ($i = 1; $i < 876; $i++) system("touch test$i.txt");'
cd ../
zip -r test2.zip test2 > /dev/null
php -r '$zip = new ZipArchive(); var_dump($zip->open("test2.zip"));
var_dump($zip->numFiles);'

Expected result:
----------------
[mas at sw-nbk01 zip]$ sh ./zip.sh 
bool(true)
int(800)
bool(true)
int(876)

Actual result:
--------------
[mas at www zip]$ sh ./zip.sh 
bool(true)
int(800)
int(5)
int(0)

Reference: http://bugs.php.net/bug.php?id=40873

-If you would like there is a patch but you'll have to recompile the php
from source. Patch is 100% working

--- php-5.2.5/ext/zip/lib/zip_open.c.seek_error 2008-02-05
22:05:03.000000000 +0200                                                
                         
+++ php-5.2.5/ext/zip/lib/zip_open.c    2008-02-05 23:17:05.000000000
+0200                                                                   
              
@@ -313,7 +313,7 @@                                                     
                                                                        
           
        /* go to start of cdir and read it entry by entry */            
                                                                        
           
        bufp = NULL;                                                    
                                                                        
           
        clearerr(fp);                                                   
                                                                        
           
-       fseek(fp, -(cd->size+cd->comment_len+EOCDLEN), SEEK_END);       
                                                                        
           
+       fseek(fp, -((long)(cd->size+cd->comment_len+EOCDLEN)),
SEEK_END);                                                              
                     
        if (ferror(fp) || ((unsigned int)ftell(fp) != cd->offset)) {    
                                                                        
           
            /* seek error or offset of cdir wrong */                    
                                                                        
           
            if (ferror(fp))                

Reference: http://bugs.php.net/bug.php?id=44055

** Affects: php5 (Ubuntu)
     Importance: Undecided
         Status: New

-- 
Compiled zip support in PHP 5.2.4 64bit can't open archives with large number of files.
https://bugs.launchpad.net/bugs/406303
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to php5 in ubuntu.



More information about the Ubuntu-server-bugs mailing list