summaryrefslogtreecommitdiff
path: root/ext/phar/tests
diff options
context:
space:
mode:
authorGreg Beaver <cellog@php.net>2005-12-10 02:33:35 +0000
committerGreg Beaver <cellog@php.net>2005-12-10 02:33:35 +0000
commitbbbd9ba1f1ecf2989d80d3ad5b5bbf6ddc663f23 (patch)
treea91c30b7af772bffd8a0025352a8f50d232e4290 /ext/phar/tests
parent0552791eca832047e532b0f38d8c5d358098a016 (diff)
downloadphp-git-bbbd9ba1f1ecf2989d80d3ad5b5bbf6ddc663f23.tar.gz
add missing tests
Diffstat (limited to 'ext/phar/tests')
-rw-r--r--ext/phar/tests/010.phpt20
-rw-r--r--ext/phar/tests/011.phpt20
2 files changed, 40 insertions, 0 deletions
diff --git a/ext/phar/tests/010.phpt b/ext/phar/tests/010.phpt
new file mode 100644
index 0000000000..55d986631a
--- /dev/null
+++ b/ext/phar/tests/010.phpt
@@ -0,0 +1,20 @@
+--TEST--
+PHP_Archive::mapPhar buffer overrun
+--SKIPIF--
+<?php if (!extension_loaded("phar")) print "skip";?>
+--FILE--
+<?php
+function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
+register_shutdown_function('cleanup');
+$file = "<?php
+PHP_Archive::mapPhar(5, 'hio', false);
+__HALT_COMPILER(); ?>";
+$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 1);
+// this fails because the manifest length does not include the 4-byte "length of manifest" data
+$file .= pack('VV', strlen($manifest), 1) . $manifest . pack('VV', crc32('a'), 1) . 'a';
+file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
+include dirname(__FILE__) . '/008_phar.php';
+echo file_get_contents('phar://hio/a');
+?>
+--EXPECTF--
+Fatal error: PHP_Archive::mapPhar(): internal corruption of phar "%s" (buffer overrun) in %s on line %d \ No newline at end of file
diff --git a/ext/phar/tests/011.phpt b/ext/phar/tests/011.phpt
new file mode 100644
index 0000000000..d98042be12
--- /dev/null
+++ b/ext/phar/tests/011.phpt
@@ -0,0 +1,20 @@
+--TEST--
+PHP_Archive::mapPhar filesize too small in manifest
+--SKIPIF--
+<?php if (!extension_loaded("phar")) print "skip";?>
+--FILE--
+<?php
+function cleanup() { unlink(dirname(__FILE__) . '/008_phar.php'); }
+register_shutdown_function('cleanup');
+$file = "<?php
+PHP_Archive::mapPhar(5, 'hio', false);
+__HALT_COMPILER(); ?>";
+// compressed file length does not include 8 bytes for crc/file length and should
+$manifest = pack('V', 1) . 'a' . pack('VVVV', 1, time(), 0, 1);
+$file .= pack('VV', strlen($manifest) + 4, 1) . $manifest . pack('VV', crc32('a'), 1) . 'a';
+file_put_contents(dirname(__FILE__) . '/008_phar.php', $file);
+include dirname(__FILE__) . '/008_phar.php';
+echo file_get_contents('phar://hio/a');
+?>
+--EXPECTF--
+Fatal error: PHP_Archive::mapPhar(): internal corruption of phar "%s" (file size in phar is not large enough) in %s on line %d \ No newline at end of file