File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1472,6 +1472,21 @@ static ZIPARCHIVE_METHOD(open)
14721472 ze_obj -> filename = NULL ;
14731473 }
14741474
1475+ #if LIBZIP_VERSION_MAJOR > 1 || LIBZIP_VERSION_MAJOR == 1 && LIBZIP_VERSION_MINOR >= 6
1476+ /* reduce BC break introduce in libzip 1.6.0
1477+ "Do not accept empty files as valid zip archives any longer" */
1478+
1479+ /* open for write without option to empty the archive */
1480+ if ((flags & (ZIP_TRUNCATE | ZIP_RDONLY )) == 0 ) {
1481+ zend_stat_t st ;
1482+
1483+ /* exists and is empty */
1484+ if (VCWD_STAT (resolved_path , & st ) == 0 && st .st_size == 0 ) {
1485+ flags |= ZIP_TRUNCATE ;
1486+ }
1487+ }
1488+ #endif
1489+
14751490 intern = zip_open (resolved_path , flags , & err );
14761491 if (!intern || err ) {
14771492 efree (resolved_path );
You can’t perform that action at this time.
0 commit comments