diff options
author | Pierre Joye <pajoye@php.net> | 2010-02-01 20:56:03 +0000 |
---|---|---|
committer | Pierre Joye <pajoye@php.net> | 2010-02-01 20:56:03 +0000 |
commit | 3ef47217d7b96a92de3497859f246b6de04681e8 (patch) | |
tree | b079a7be47aeeace142ae29d9d24b53675fa9529 /ext/zip/lib/zip_open.c | |
parent | fa197ab9cc2ebc6c47bb26299cc5a0035e0b772f (diff) | |
download | php-git-3ef47217d7b96a92de3497859f246b6de04681e8.tar.gz |
- update to 0.9.3
Diffstat (limited to 'ext/zip/lib/zip_open.c')
-rw-r--r-- | ext/zip/lib/zip_open.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c index e3840197dd..31e12f4fc5 100644 --- a/ext/zip/lib/zip_open.c +++ b/ext/zip/lib/zip_open.c @@ -162,6 +162,7 @@ _zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen, struct zip_cdir *cd; unsigned char *cdp, **bufp; int i, comlen, nentry; + unsigned int left; comlen = buf + buflen - eocd - EOCDLEN; if (comlen < 0) { @@ -215,7 +216,6 @@ _zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen, } } - cdp = eocd; if (cd->size < (unsigned int)(eocd-buf)) { /* if buffer already read in, use it */ cdp = eocd - cd->size; @@ -239,14 +239,23 @@ _zip_readcdir(FILE *fp, unsigned char *buf, unsigned char *eocd, int buflen, } } - for (i=0; i<cd->nentry; i++) { - if ((_zip_dirent_read(cd->entry+i, fp, bufp, eocd-cdp, 0, - error)) < 0) { + left = cd->size; + i=0; + do { + if (i == cd->nentry && left > 0) { + /* Infozip extension for more than 64k entries: + nentries wraps around, size indicates correct EOCD */ + _zip_cdir_grow(cd, cd->nentry+0x10000, error); + } + + if ((_zip_dirent_read(cd->entry+i, fp, bufp, &left, 0, error)) < 0) { cd->nentry = i; _zip_cdir_free(cd); return NULL; } - } + i++; + + } while (i<cd->nentry); return cd; } @@ -295,7 +304,7 @@ _zip_checkcons(FILE *fp, struct zip_cdir *cd, struct zip_error *error) return -1; } - if (_zip_dirent_read(&temp, fp, NULL, 0, 1, error) == -1) + if (_zip_dirent_read(&temp, fp, NULL, NULL, 1, error) == -1) return -1; if (_zip_headercomp(cd->entry+i, 0, &temp, 1) != 0) { |