diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2021-01-20 15:24:47 +0100 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2021-01-20 16:20:13 +0100 |
commit | 6adfb8c9621578c7ebb84091695d6cdc65cc0634 (patch) | |
tree | f8db0152b6ed1c356fc9e552277cf3f0c389c418 | |
parent | 4c1b3e3036ff275b2a848bdba5a93b1ca486382b (diff) | |
download | php-git-6adfb8c9621578c7ebb84091695d6cdc65cc0634.tar.gz |
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.
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ext/zip/php_zip.c | 11 |
2 files changed, 10 insertions, 5 deletions
@@ -2,6 +2,10 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2021, PHP 7.4.16 +- Zip: + . Fixed bug #80648 (Fix for bug 79296 should be based on runtime version). + (cmb, Remi) + 21 Jan 2021, PHP 7.4.15 - Core: diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 883b6f6d40..21182068d1 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1473,20 +1473,21 @@ static ZIPARCHIVE_METHOD(open) ze_obj->filename = NULL; } -#if LIBZIP_VERSION_MAJOR > 1 || LIBZIP_VERSION_MAJOR == 1 && LIBZIP_VERSION_MINOR >= 6 - /* reduce BC break introduce in libzip 1.6.0 - "Do not accept empty files as valid zip archives any longer" */ - /* open for write without option to empty the archive */ +#ifdef ZIP_RDONLY if ((flags & (ZIP_TRUNCATE | ZIP_RDONLY)) == 0) { +#else + if ((flags & ZIP_TRUNCATE) == 0) { +#endif zend_stat_t st; /* exists and is empty */ if (VCWD_STAT(resolved_path, &st) == 0 && st.st_size == 0) { + /* reduce BC break introduced in libzip 1.6.0 + "Do not accept empty files as valid zip archives any longer" */ flags |= ZIP_TRUNCATE; } } -#endif intern = zip_open(resolved_path, flags, &err); if (!intern || err) { |