summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAnatoliy Belsky <ab@php.net>2012-06-07 14:27:47 (GMT)
committerAnatoliy Belsky <ab@php.net>2012-06-07 19:01:32 (GMT)
commit8ca457f64dadff756831bc61abf479a4159b2072 (patch)
tree3332dfc193f9de1fa7f2515824d9a866a8c516ba /ext
parente8838926644cfb9a0ec9525a5b519da15b3e022a (diff)
downloadphp-8ca457f64dadff756831bc61abf479a4159b2072.tar.gz
fixed bc break related to #57905
Diffstat (limited to 'ext')
-rw-r--r--ext/zip/lib/zip_open.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/zip/lib/zip_open.c b/ext/zip/lib/zip_open.c
index 2f56881..a348d98 100644
--- a/ext/zip/lib/zip_open.c
+++ b/ext/zip/lib/zip_open.c
@@ -206,7 +206,9 @@ _zip_readcdir(FILE *fp, off_t buf_offset, unsigned char *buf, unsigned char *eoc
cd->comment = NULL;
cd->comment_len = _zip_read2(&cdp);
- if (((zip_uint64_t)cd->offset)+cd->size > buf_offset + (eocd-buf)) {
+ /* without checking the ZIP_CHECKCONS flag we'll not able even to open inconsistent
+ archives at this place, which would break bc in PHP */
+ if ((ZIP_CHECKCONS == (flags & ZIP_CHECKCONS)) && ((zip_uint64_t)cd->offset)+cd->size > buf_offset + (eocd-buf)) {
/* cdir spans past EOCD record */
_zip_error_set(error, ZIP_ER_INCONS, 0);
cd->nentry = 0;
@@ -237,7 +239,13 @@ _zip_readcdir(FILE *fp, off_t buf_offset, unsigned char *buf, unsigned char *eoc
}
}
- if (cd->offset >= buf_offset) {
+ /* the first if branch goes the old way of libzip 0.9 so we don't loose
+ the bc for reading inconsistent files */
+ if ((ZIP_CHECKCONS != (flags & ZIP_CHECKCONS)) && cd->size < (unsigned int)(eocd-buf)) {
+ cdp = eocd - cd->size;
+ bufp = &cdp;
+ }
+ else if (cd->offset >= buf_offset) {
/* if buffer already read in, use it */
cdp = buf + (cd->offset - buf_offset);
bufp = &cdp;