From: Marcus Boerger Date: Mon, 5 Feb 2007 20:47:20 +0000 (+0000) Subject: - Add additional check & test X-Git-Tag: RELEASE_1_0_0RC1~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=357b931e56714aa0b34655856a60404c55533b9a;p=php - Add additional check & test --- diff --git a/ext/phar/phar.c b/ext/phar/phar.c index cd427ec363..85bc153cc6 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1876,7 +1876,7 @@ int phar_flush(phar_archive_data *archive, char *user_stub, long len, char **err static const char newstub[] = "halt_offset = offset; } else { + if ((pos = strstr(user_stub, "__HALT_COMPILER();")) == NULL) + { + if (error) { + spprintf(error, 0, "illegal stub for phar \"%s\"", archive->fname); + } + return EOF; + } if ((size_t)len != php_stream_write(newfile, user_stub, len)) { if (closeoldfile) { php_stream_close(oldfile); diff --git a/ext/phar/tests/phar_stub_error.phpt b/ext/phar/tests/phar_stub_error.phpt new file mode 100755 index 0000000000..e8a3811b5d --- /dev/null +++ b/ext/phar/tests/phar_stub_error.phpt @@ -0,0 +1,56 @@ +--TEST-- +Phar::setStub()/getStub() +--SKIPIF-- + +--INI-- +phar.require_hash=0 +phar.readonly=0 +--FILE-- +'; +$file = $stub; + +$files = array(); +$files['a'] = 'a'; + +include 'phar_test.inc'; + +$phar = new Phar($fname); +var_dump($stub); +var_dump($phar->getStub()); +var_dump($phar->getStub() == $stub); + +$newstub = ''; +try +{ + $phar->setStub($newstub); +} +catch(exception $e) +{ + echo 'Exception: ' . $e->getMessage() . "\n"; +} +var_dump($phar->getStub()); +var_dump($phar->getStub() == $stub); +$phar->commit(); +var_dump($phar->getStub()); +var_dump($phar->getStub() == $stub); + +?> +===DONE=== +--CLEAN-- + +--EXPECTF-- +string(48) "" +string(48) "" +bool(true) +Exception: illegal stub for phar "%sphar_stub_error.phar.php" +string(48) "" +bool(true) +string(48) "" +bool(true) +===DONE===