From: Greg Beaver Date: Thu, 8 Dec 2005 07:08:49 +0000 (+0000) Subject: add next truncation test, tweak error messages X-Git-Tag: RELEASE_1_0_4~472 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=919b0736c5ab1013bd8d5b7e36fcc3e18619715f;p=php add next truncation test, tweak error messages --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index b5231a2f44..04a0475e68 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -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 index 0000000000..07992a4b70 --- /dev/null +++ b/ext/phar/tests/006.phpt @@ -0,0 +1,10 @@ +--TEST-- +PHP_Archive::mapPhar improper parameters +--SKIPIF-- + +--FILE-- +()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