Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-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. Closes GH-13045.
- Loading branch information
Showing
4 changed files
with
59 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--TEST-- | ||
GH-13037 (PharData incorrectly extracts zip file) | ||
--EXTENSIONS-- | ||
phar | ||
--FILE-- | ||
<?php | ||
$phar = new PharData(__DIR__ . '/files/gh13037.zip'); | ||
$phar->extractTo(__DIR__ . '/out_gh13037/'); | ||
echo file_get_contents(__DIR__ . '/out_gh13037/test'); | ||
?> | ||
--CLEAN-- | ||
<?php | ||
@unlink(__DIR__ . '/out_gh13037/test'); | ||
@rmdir(__DIR__ . '/out_gh13037'); | ||
?> | ||
--EXPECT-- | ||
hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters