Skip to content

Commit d3780f1

Browse files
committed
Reverted the BC fix regarding to #57905, test adopted
New 0.10.1 has a stronger archive integrity check. Restoring the old behaviour of libzip < 0.10.1 makes no sense at this place.
1 parent 26cb570 commit d3780f1

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

ext/zip/lib/zip_open.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ _zip_readcdir(FILE *fp, off_t buf_offset, unsigned char *buf, unsigned char *eoc
206206
cd->comment = NULL;
207207
cd->comment_len = _zip_read2(&cdp);
208208

209-
/* without checking the ZIP_CHECKCONS flag we'll not able even to open inconsistent
210-
archives at this place, which would break bc in PHP */
211-
if ((ZIP_CHECKCONS == (flags & ZIP_CHECKCONS)) && ((zip_uint64_t)cd->offset)+cd->size > buf_offset + (eocd-buf)) {
209+
if (((zip_uint64_t)cd->offset)+cd->size > buf_offset + (eocd-buf)) {
212210
/* cdir spans past EOCD record */
213211
_zip_error_set(error, ZIP_ER_INCONS, 0);
214212
cd->nentry = 0;
@@ -239,13 +237,7 @@ _zip_readcdir(FILE *fp, off_t buf_offset, unsigned char *buf, unsigned char *eoc
239237
}
240238
}
241239

242-
/* the first if branch goes the old way of libzip 0.9 so we don't loose
243-
the bc for reading inconsistent files */
244-
if ((ZIP_CHECKCONS != (flags & ZIP_CHECKCONS)) && cd->size < (unsigned int)(eocd-buf)) {
245-
cdp = eocd - cd->size;
246-
bufp = &cdp;
247-
}
248-
else if (cd->offset >= buf_offset) {
240+
if (cd->offset >= buf_offset) {
249241
/* if buffer already read in, use it */
250242
cdp = buf + (cd->offset - buf_offset);
251243
bufp = &cdp;

ext/zip/tests/pecl12414.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,4 @@ if ($res === TRUE) {
3535
?>
3636
--DONE--
3737
--EXPECTF--
38-
ZIP contents size: %d
39-
zip_readfile recorded data does not match unpacked size: %specl12414.zip : MYLOGOV2.GFX
38+
zip_readfile could not read from %specl12414.zip : MYLOGOV2.GFX

0 commit comments

Comments
 (0)