1
0
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:
Greg Beaver
2008-04-20 15:12:09 +00:00
parent 8001dfd8d0
commit f5dbaf64fc
2 changed files with 24 additions and 2 deletions
+2 -2
View File
@@ -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);
+22
View File
@@ -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===