Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
281 changes: 211 additions & 70 deletions ext/phar/tar.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly move where the bail: label is? It is somewhat confusing that we go "back up" to do error handling rather than the usual "go to end of function" style for error handling. As I needed to look up the full function code to locate the label.

May be a follow-up PR/commit or be a new commit in this change set.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions ext/phar/tests/tar/pax/gh19311.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
GH-19311 (Unexpected path truncation of files contained in a tar file by PharData::extractTo())
--EXTENSIONS--
phar
--FILE--
<?php

$tar = new PharData(__DIR__ . '/../files/gh19311/pax_local_path_override.tar');
foreach (new RecursiveIteratorIterator($tar) as $file) {
echo $file->getPathname(), "\n";
}

?>
--EXPECTF--
phar://%s/pax_local_path_override.tar/a-very-long-path/to-a-file/with-a-very-long-name/in-a-deep-directory-structure/a-php-file-with-a-very-long-name.php
16 changes: 16 additions & 0 deletions ext/phar/tests/tar/pax/global_hdrcharset.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Global hdrcharset
--EXTENSIONS--
phar
--FILE--
<?php

$tar = new PharData(__DIR__ . '/../files/gh19311/global_hdrcharset.tar');
foreach (new RecursiveIteratorIterator($tar) as $file) {
echo $file->getPathname(), "\n";
}

?>
--EXPECTF--
Notice: PharData::__construct(): Global PAX header component not understood: invalid header character set in %s on line %d
phar://%s/global_hdrcharset.tar/example.txt
16 changes: 16 additions & 0 deletions ext/phar/tests/tar/pax/global_path_override.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Global path override with PAX header
--EXTENSIONS--
phar
--FILE--
<?php

try {
new PharData(__DIR__ . '/../files/gh19311/global_path_override.tar');
} catch (UnexpectedValueException $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECTF--
phar error: "%s" is a corrupted tar file (invalid global pax header: unsupported global path override)
16 changes: 16 additions & 0 deletions ext/phar/tests/tar/pax/local_hdrcharset.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Local hdrcharset
--EXTENSIONS--
phar
--FILE--
<?php

$tar = new PharData(__DIR__ . '/../files/gh19311/local_hdrcharset.tar');
foreach (new RecursiveIteratorIterator($tar) as $file) {
echo $file->getPathname(), "\n";
}

?>
--EXPECTF--
Notice: PharData::__construct(): File PAX header component not understood: invalid header character set in %s on line %d
phar://%s/local_hdrcharset.tar/example.txt
16 changes: 16 additions & 0 deletions ext/phar/tests/tar/pax/path_edge_case.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Path edge case
--EXTENSIONS--
phar
--FILE--
<?php

$tar = new PharData(__DIR__ . '/../files/gh19311/path_edge_case.tar');
foreach (new RecursiveIteratorIterator($tar) as $file) {
echo $file->getPathname(), "\n";
}

?>
--EXPECTF--
Notice: PharData::__construct(): File PAX header component not understood: invalid path length in %s on line %d
phar://%s/path_edge_case.tar/example.txt