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;
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);
--- /dev/null
+--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===