Skip to content

Commit 217ff81

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: unneeded after fix NEWS NEWS Fix Bug #79296 ZipArchive::open fails on empty file
2 parents 517c30b + 347d18b commit 217ff81

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

ext/zip/php_zip.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,21 @@ static ZIPARCHIVE_METHOD(open)
14871487
ze_obj->filename = NULL;
14881488
}
14891489

1490+
#if LIBZIP_VERSION_MAJOR > 1 || LIBZIP_VERSION_MAJOR == 1 && LIBZIP_VERSION_MINOR >= 6
1491+
/* reduce BC break introduce in libzip 1.6.0
1492+
"Do not accept empty files as valid zip archives any longer" */
1493+
1494+
/* open for write without option to empty the archive */
1495+
if ((flags & (ZIP_TRUNCATE | ZIP_RDONLY)) == 0) {
1496+
zend_stat_t st;
1497+
1498+
/* exists and is empty */
1499+
if (VCWD_STAT(resolved_path, &st) == 0 && st.st_size == 0) {
1500+
flags |= ZIP_TRUNCATE;
1501+
}
1502+
}
1503+
#endif
1504+
14901505
intern = zip_open(resolved_path, flags, &err);
14911506
if (!intern || err) {
14921507
efree(resolved_path);

ext/zip/tests/bug53885.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ Bug #53885 (ZipArchive segfault with FL_UNCHANGED on empty archive)
33
--SKIPIF--
44
<?php
55
if(!extension_loaded('zip')) die('skip');
6-
if(version_compare(ZipArchive::LIBZIP_VERSION, '1.6', '>=')) die('skip libzip too recent');
76
?>
87
--FILE--
98
<?php

0 commit comments

Comments
 (0)