Fix bug #73035 (Out of bound when verify signature of tar phar in phar_parse_tarfile)

This commit is contained in:
Stanislav Malyshev 2016-09-11 21:37:44 -07:00
parent 6a7cc8ff85
commit f5a9592ad8
3 changed files with 19 additions and 1 deletions

View file

@ -286,7 +286,7 @@ bail:
}
curloc = php_stream_tell(fp);
read = php_stream_read(fp, buf, size);
if (read != size) {
if (read != size || read <= 8) {
if (error) {
spprintf(error, 4096, "phar error: tar-based phar \"%s\" signature cannot be read", fname);
}

View file

@ -0,0 +1,18 @@
--TEST--
Phar: #73035 (Out of bound when verify signature of tar phar in phar_parse_tarfile)
--SKIPIF--
<?php if (!extension_loaded("phar")) die("skip"); ?>
--FILE--
<?php
chdir(__DIR__);
try {
$phar = new PharData('bug73035.tar');
var_dump($phar);
} catch(UnexpectedValueException $e) {
print $e->getMessage()."\n";
}
?>
DONE
--EXPECTF--
phar error: tar-based phar "%sbug73035.tar" signature cannot be read
DONE

BIN
ext/phar/tests/bug73035.tar Normal file

Binary file not shown.