From f5dbaf64fc17014d0d4bc51fafc3c77d571ea38f Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Sun, 20 Apr 2008 15:12:09 +0000 Subject: [PATCH] add failing test for truncated tar archive --- ext/phar/tar.c | 4 ++-- ext/phar/tests/tar/truncated.phpt | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 ext/phar/tests/tar/truncated.phpt diff --git a/ext/phar/tar.c b/ext/phar/tar.c index 17b6a7e9fc..343ee2b14b 100644 --- a/ext/phar/tar.c +++ b/ext/phar/tar.c @@ -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); diff --git a/ext/phar/tests/tar/truncated.phpt b/ext/phar/tests/tar/truncated.phpt new file mode 100644 index 0000000000..fbcabb7986 --- /dev/null +++ b/ext/phar/tests/tar/truncated.phpt @@ -0,0 +1,22 @@ +--TEST-- +Phar: truncated tar +--SKIPIF-- + +--FILE-- +getMessage() . "\n"; +} + +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +phar error: "%strunc.tar" is a corrupted tar file (truncated) +===DONE=== -- 2.50.1