mirror of
https://github.com/php/php-src.git
synced 2026-04-26 17:38:14 +02:00
new test for truncated file comment, fix memleak found by test
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
Phar: corrupted zip (truncated file comment)
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("phar")) die("skip"); ?>
|
||||
<?php if (!extension_loaded("spl")) die("skip SPL not available"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
try {
|
||||
new PharData(dirname(__FILE__) . '/files/filecomment.zip');
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage() . "\n";
|
||||
}
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
phar error: corrupt zip archive, zip file comment truncated in zip-based phar "%sfilecomment.zip"
|
||||
===DONE===
|
||||
@@ -6,4 +6,5 @@ $a->addFile('hi2', null, 'hii2');
|
||||
$a->writeZip(dirname(__FILE__) . '/count1.zip', 'count1');
|
||||
$a->writeZip(dirname(__FILE__) . '/count2.zip', 'count2');
|
||||
$a->writeZip(dirname(__FILE__) . '/nozipend.zip', 'none');
|
||||
$a->writeZip(dirname(__FILE__) . '/filecomment.zip', 'comment');
|
||||
?>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -212,9 +212,13 @@ foundit:
|
||||
if (locator.comment_len) {
|
||||
metadata = (char *) emalloc(PHAR_GET_16(locator.comment_len));
|
||||
if (locator.comment_len != php_stream_read(fp, metadata, PHAR_GET_16(locator.comment_len))) {
|
||||
if (error) {
|
||||
spprintf(error, 4096, "phar error: corrupt zip archive, zip file comment truncated in zip-based phar \"%s\"", fname);
|
||||
}
|
||||
php_stream_close(fp);
|
||||
efree(mydata->fname);
|
||||
efree(mydata);
|
||||
efree(metadata);
|
||||
return FAILURE;
|
||||
}
|
||||
if (phar_parse_metadata(&metadata, &mydata->metadata, PHAR_GET_16(locator.comment_len) TSRMLS_CC) == FAILURE) {
|
||||
|
||||
Reference in New Issue
Block a user