mirror of
https://github.com/php/php-src.git
synced 2026-04-29 03:03:26 +02:00
add failing test for truncated tar archive
This commit is contained in:
+2
-2
@@ -164,7 +164,7 @@ int phar_open_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, i
|
||||
read = php_stream_read(fp, buf, sizeof(buf));
|
||||
if (read != sizeof(buf)) {
|
||||
if (error) {
|
||||
spprintf(error, 4096, "phar error: \"%s\" is not a tar file", fname);
|
||||
spprintf(error, 4096, "phar error: \"%s\" is not a tar file or is truncated", fname);
|
||||
}
|
||||
php_stream_close(fp);
|
||||
return FAILURE;
|
||||
@@ -187,7 +187,7 @@ int phar_open_tarfile(php_stream* fp, char *fname, int fname_len, char *alias, i
|
||||
do {
|
||||
if (read != sizeof(buf)) {
|
||||
if (error) {
|
||||
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file", fname);
|
||||
spprintf(error, 4096, "phar error: \"%s\" is a corrupted tar file (truncated)", fname);
|
||||
}
|
||||
php_stream_close(fp);
|
||||
zend_hash_destroy(&myphar->manifest);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Phar: truncated tar
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
try {
|
||||
$p = new PharData(dirname(__FILE__) . '/files/trunc.tar');
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--CLEAN--
|
||||
<?php
|
||||
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar.tar');
|
||||
unlink(dirname(__FILE__) . '/' . basename(__FILE__, '.clean.php') . '.phar');
|
||||
?>
|
||||
--EXPECTF--
|
||||
phar error: "%strunc.tar" is a corrupted tar file (truncated)
|
||||
===DONE===
|
||||
Reference in New Issue
Block a user