]> granicus.if.org Git - php/commitdiff
add next truncation test, tweak error messages
authorGreg Beaver <cellog@php.net>
Thu, 8 Dec 2005 07:08:49 +0000 (07:08 +0000)
committerGreg Beaver <cellog@php.net>
Thu, 8 Dec 2005 07:08:49 +0000 (07:08 +0000)
ext/phar/phar.c
ext/phar/tests/006.phpt [new file with mode: 0644]

index b5231a2f44b6a966fac3564c6a43ea36aa0433e9..04a0475e68b0a2b2b6ca9c788ccd0f74fe45a5be 100644 (file)
@@ -167,8 +167,8 @@ PHP_METHOD(PHP_Archive, mapPhar)
                MAPPHAR_ALLOC_FAIL(msg)
 
        // check for ?>\n and increment accordingly
-       if (0 == php_stream_seek(fp, halt_offset, SEEK_SET)) {
-               MAPPHAR_FAIL("cannot seek to __HALT_COMPILER() location in phar \"%s\"")
+       if (-1 == php_stream_seek(fp, halt_offset, SEEK_SET)) {
+               MAPPHAR_FAIL("cannot seek to __HALT_COMPILER(); location in phar \"%s\"")
        }
 
        if (FALSE == (buffer = (char *) emalloc(4))) {
@@ -194,7 +194,9 @@ PHP_METHOD(PHP_Archive, mapPhar)
                }
        }
        // make sure we are at the right location to read the manifest
-       php_stream_seek(fp, halt_offset, SEEK_SET);
+       if (-1 == php_stream_seek(fp, halt_offset, SEEK_SET)) {
+               MAPPHAR_FAIL("cannot seek to __HALT_COMPILER(); location in phar \"%s\"")
+       }
 
        // read in manifest
 
diff --git a/ext/phar/tests/006.phpt b/ext/phar/tests/006.phpt
new file mode 100644 (file)
index 0000000..07992a4
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--
+PHP_Archive::mapPhar improper parameters
+--SKIPIF--
+<?php if (!extension_loaded("phar")) print "skip";?>
+--FILE--
+<?php
+PHP_Archive::mapPhar(5, 'hio', false);
+__HALT_COMPILER(); ?>()a
+--EXPECTF--
+Fatal error: PHP_Archive::mapPhar(): internal corruption of phar "%s" (truncated manifest) in %s on line %d
\ No newline at end of file