File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1487,6 +1487,21 @@ static ZIPARCHIVE_METHOD(open)
1487
1487
ze_obj -> filename = NULL ;
1488
1488
}
1489
1489
1490
+ #if LIBZIP_VERSION_MAJOR > 1 || LIBZIP_VERSION_MAJOR == 1 && LIBZIP_VERSION_MINOR >= 6
1491
+ /* reduce BC break introduce in libzip 1.6.0
1492
+ "Do not accept empty files as valid zip archives any longer" */
1493
+
1494
+ /* open for write without option to empty the archive */
1495
+ if ((flags & (ZIP_TRUNCATE | ZIP_RDONLY )) == 0 ) {
1496
+ zend_stat_t st ;
1497
+
1498
+ /* exists and is empty */
1499
+ if (VCWD_STAT (resolved_path , & st ) == 0 && st .st_size == 0 ) {
1500
+ flags |= ZIP_TRUNCATE ;
1501
+ }
1502
+ }
1503
+ #endif
1504
+
1490
1505
intern = zip_open (resolved_path , flags , & err );
1491
1506
if (!intern || err ) {
1492
1507
efree (resolved_path );
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ Bug #53885 (ZipArchive segfault with FL_UNCHANGED on empty archive)
3
3
--SKIPIF--
4
4
<?php
5
5
if (!extension_loaded ('zip ' )) die ('skip ' );
6
- if (version_compare (ZipArchive::LIBZIP_VERSION , '1.6 ' , '>= ' )) die ('skip libzip too recent ' );
7
6
?>
8
7
--FILE--
9
8
<?php
You can’t perform that action at this time.
0 commit comments