diff options
author | Remi Collet <remi@php.net> | 2020-03-20 11:16:38 +0100 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2020-03-20 11:16:38 +0100 |
commit | 98687abb1da7b10b754e3aac9fbe54b131988d5c (patch) | |
tree | 324b1efe51affe9adc5e03f739550c72ea3464c8 /ext/zip | |
parent | 673a3ceaa23738349e7a9a05445a3741d41b075c (diff) | |
parent | 51c57a9c677f81bf70e64b2b10d44d04d2cdf0ea (diff) | |
download | php-git-98687abb1da7b10b754e3aac9fbe54b131988d5c.tar.gz |
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
NEWS
Fix Bug #79296 ZipArchive::open fails on empty file
Diffstat (limited to 'ext/zip')
-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 9d704b0cbf..5dd6d8f29e 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1472,6 +1472,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); |