mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
There are two issues: 1) There's an off-by-one in the check for the minimum file size for a tar (i.e. `>` instead of `>=`). 2) The loop in the tar parsing parses a header, and then unconditionally reads the next one. However, that doesn't necessarily exist. Instead, we remove the loop condition and check for the end of the file before reading the next header. Note that we can't use php_stream_eof as the flag may not be set yet when we're already at the end. Closes GH-16700.
27 lines
1.1 KiB
PHP
27 lines
1.1 KiB
PHP
--TEST--
|
|
GH-16695 (phar:// tar parser and zero-length file header blocks)
|
|
--CREDITS--
|
|
hakre
|
|
--EXTENSIONS--
|
|
phar
|
|
--INI--
|
|
phar.require_hash=0
|
|
--FILE--
|
|
<?php
|
|
|
|
$reportTar = __DIR__.'/gh16695_3.tmp';
|
|
|
|
$length = file_put_contents($reportTar, base64_decode('dGxzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAwMDA3MDAAMDAwMDAwMAAwMDAwMDAwADAwMDAwMDAwMDAwADAwMDAwMDAwMDAwADAwNzcxMQAgMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB1c3RhcgAwMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwMDAwMDAwADAwMDAwMDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='));
|
|
var_dump($length);
|
|
$buffer = file_get_contents("phar://$reportTar/tls");
|
|
var_dump($buffer);
|
|
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
@unlink(__DIR__.'/gh16695_3.tmp');
|
|
?>
|
|
--EXPECT--
|
|
int(512)
|
|
string(0) ""
|