1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 09:12:14 +01:00

increase code coverage

This commit is contained in:
Greg Beaver
2008-08-11 03:53:57 +00:00
parent 18d07065c0
commit 8526b78286
4 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
--TEST--
Phar: corrupted zip (extra field way too long)
--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/extralen_toolong.zip');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}
?>
===DONE===
--EXPECTF--
phar error: Unable to process extra field header for file in central directory in zip-based phar "%sextralen_toolong.zip"
===DONE===

View File

@@ -0,0 +1,6 @@
<?php
include dirname(__FILE__) . '/corrupt_zipmaker.php.inc';
$a = new corrupt_zipmaker;
$a->addFile('hi', null, 'hii', null, null, null, 'extralen1');
$a->writeZip(dirname(__FILE__) . '/extralen_toolong.zip');
?>

View File

@@ -237,6 +237,15 @@ class corrupt_zipmaker
$filename . $comment;
$offset = strlen($central);
break;
case 'extralen1' :
$extra = 'nu' . 0xffff; // way huge size
$central = "PK\x01\x02\x00\x00\x14\x00\x00\x00" . pack('v', $compmethod) .
$mtime .
pack("VVVvvvvvVV", $crc32, $complength, $uncomplength, strlen($filename), strlen($extra),strlen($comment),0x00,0x00,
0x0000, $this->offset).
$filename . $extra . $comment;
$offset = strlen($central);
break;
}
return $central;
}

Binary file not shown.