You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FixphpGH-13037: PharData incorrectly extracts zip file
The code currently assumes that the extra field length of the central
directory entry and the local entry are the same, but that's not the
case. For example, the "Extended Timestamp extra field" differs in size
for local vs central directory entries. This causes the file contents
offset to be incorrect because it is based on the central directory
length instead of the local entry length. Fix it by reading the local
entry and getting the size from there as well as checking consistency
for the file name length.
ClosesphpGH-13045.
if (sizeof(local) !=php_stream_read(fp, (char*) &local, sizeof(local))) {
575
-
pefree(entry.filename, entry.is_persistent);
576
-
PHAR_ZIP_FAIL("phar error: internal corruption of zip-based phar (cannot read local file header for alias)");
577
-
}
578
602
579
603
/* verify local header */
580
-
if (entry.filename_len!=PHAR_GET_16(local.filename_len) ||entry.crc32!=PHAR_GET_32(local.crc32) ||entry.uncompressed_filesize!=PHAR_GET_32(local.uncompsize) ||entry.compressed_filesize!=PHAR_GET_32(local.compsize)) {
604
+
ZEND_ASSERT(!entry.is_dir);
605
+
if (entry.crc32!=PHAR_GET_32(local.crc32) ||entry.uncompressed_filesize!=PHAR_GET_32(local.uncompsize) ||entry.compressed_filesize!=PHAR_GET_32(local.compsize)) {
581
606
pefree(entry.filename, entry.is_persistent);
582
607
PHAR_ZIP_FAIL("phar error: internal corruption of zip-based phar (local header of alias does not match central directory)");
583
608
}
584
609
585
-
/* construct actual offset to file start - local extra_len can be different from central extra_len */
0 commit comments