From:             max630 at gmail dot com
Operating system: linux/amd64
PHP version:      5.2.5
PHP Bug Type:     Zip Related
Bug description:  ZipArchive::open() fails to open some archives

Description:
------------
ZipArchive fails on opening some zip archives

file which php fails on is here:
http://max630.info/dir900.zip

it is just 900 empty files in one directory. Produced by zip utility from
a recent Linux distribution (Debian).

This IS NOT an OS issue, as no failed syscall appears in strace. Most
probable reason is that in-source zip library is not completely ready for
64-bit wide offsets, but I'm not sure. I'm not even sure that it is the
reason of the failure is size of the archive.

I can not reopen Bug #40873 - I am not the original reporter - so here is
a new bug

BTW, libzip from
http://ftp.de.debian.org/debian/pool/main/libz/libzip/libzip_0.8-1.dsc
- which is where the builtin implementation came from - opens all files I
have tested without errors

Reproduce code:
---------------
<?php

$z = new ZipArchive;

$status = $z->open("dir900.zip");

if ($status !== TRUE) {
    print_r($status);
    die("open failed");
}

?>

Expected result:
----------------
$./sapi/cli/php test-zip.php
$

Actual result:
--------------
$./sapi/cli/php test-zip.php
5open failed
$

noteable piece from strace:
open("/home/max/dir900.zip", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=124126, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x2aaff7b39000
fstat(3, {st_mode=S_IFREG|0644, st_size=124126, ...}) = 0
lseek(3, 122880, SEEK_SET)              = 122880
read(3, "\0\0\0\0\0\0\0\0\0\0\0\16\0\r\0\0\0\0\0\0\0\0\0\244\201"...,
1246) = 1246
fstat(3, {st_mode=S_IFREG|0644, st_size=124126, ...}) = 0
lseek(3, 57344, SEEK_SET)               = 57344
read(3, "K\3\4\n\0\0\0\0\0\374x\2247\0\0\0\0\0\0\0\0\0\0\0\0\16"..., 4096)
= 4096
read(3, "\n\0\0\0\0\0\373x\2247\0\0\0\0\0\0\0\0\0\0\0\0\16\0\r\0"...,
61440) = 61440
read(3, "\0\0\0\0\0\0\0\0\0\0\0\16\0\r\0\0\0\0\0\0\0\0\0\244\201"...,
4096) = 1246
brk(0xdce000)                           = 0xdce000
fstat(3, {st_mode=S_IFREG|0644, st_size=124126, ...}) = 0
lseek(3, 4295024640, SEEK_SET)          = 4295024640
read(3, "", 4096)                       = 0
lseek(3, 1104, SEEK_CUR)                = 4295025744
read(3, "", 4096)                       = 0

Note the huge offset. I fixed this specific place
("ext/zip/lib/zip_open.c" line 316), but it still fails on some other zip
files. I could not reproduce that failure with test zip yet

-- 
Edit bug report at http://bugs.php.net/?id=43641&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=43641&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=43641&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=43641&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=43641&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=43641&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=43641&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=43641&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=43641&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=43641&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=43641&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=43641&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=43641&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=43641&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=43641&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=43641&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=43641&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=43641&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=43641&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=43641&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=43641&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=43641&r=mysqlcfg

Reply via email to