diff options
author | Remi Collet <remi@php.net> | 2020-03-20 11:19:04 +0100 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2020-03-20 11:19:04 +0100 |
commit | 217ff8132e7bc5702a1f65d7f8fa3d7c28df8e9f (patch) | |
tree | 8d3459917cb9a9e380f49d9e515097116560cdbb /ext/zip/php_zip.c | |
parent | 517c30b05feeb9a4a6156a6075e1b67b1f313e4a (diff) | |
parent | 347d18b48e984753e376d4f19a85852c433c48da (diff) | |
download | php-git-217ff8132e7bc5702a1f65d7f8fa3d7c28df8e9f.tar.gz |
Merge branch 'PHP-7.4'
* PHP-7.4:
unneeded after fix
NEWS
NEWS
Fix Bug #79296 ZipArchive::open fails on empty file
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r-- | ext/zip/php_zip.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index f9a9a8d74f..fb9d3aefec 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1487,6 +1487,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 */ + if ((flags & (ZIP_TRUNCATE | ZIP_RDONLY)) == 0) { + zend_stat_t st; + + /* exists and is empty */ + if (VCWD_STAT(resolved_path, &st) == 0 && st.st_size == 0) { + flags |= ZIP_TRUNCATE; + } + } +#endif + intern = zip_open(resolved_path, flags, &err); if (!intern || err) { efree(resolved_path); |