Skip to content

Commit 6adfb8c

Browse files
committed
Fix #80648: Fix for bug 79296 should be based on runtime version
Instead of checking for actually affected libzip versions, we now always `ZIP_TRUNCATE` empty files unless `ZIP_RDONLY` is set. Closes GH-6625.
1 parent 4c1b3e3 commit 6adfb8c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2021, PHP 7.4.16
44

5+
- Zip:
6+
. Fixed bug #80648 (Fix for bug 79296 should be based on runtime version).
7+
(cmb, Remi)
8+
59
21 Jan 2021, PHP 7.4.15
610

711
- Core:

ext/zip/php_zip.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,20 +1473,21 @@ static ZIPARCHIVE_METHOD(open)
14731473
ze_obj->filename = NULL;
14741474
}
14751475

1476-
#if LIBZIP_VERSION_MAJOR > 1 || LIBZIP_VERSION_MAJOR == 1 && LIBZIP_VERSION_MINOR >= 6
1477-
/* reduce BC break introduce in libzip 1.6.0
1478-
"Do not accept empty files as valid zip archives any longer" */
1479-
14801476
/* open for write without option to empty the archive */
1477+
#ifdef ZIP_RDONLY
14811478
if ((flags & (ZIP_TRUNCATE | ZIP_RDONLY)) == 0) {
1479+
#else
1480+
if ((flags & ZIP_TRUNCATE) == 0) {
1481+
#endif
14821482
zend_stat_t st;
14831483

14841484
/* exists and is empty */
14851485
if (VCWD_STAT(resolved_path, &st) == 0 && st.st_size == 0) {
1486+
/* reduce BC break introduced in libzip 1.6.0
1487+
"Do not accept empty files as valid zip archives any longer" */
14861488
flags |= ZIP_TRUNCATE;
14871489
}
14881490
}
1489-
#endif
14901491

14911492
intern = zip_open(resolved_path, flags, &err);
14921493
if (!intern || err) {

0 commit comments

Comments
 (0)