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:
17
ext/phar/tests/zip/corrupt_009.phpt
Normal file
17
ext/phar/tests/zip/corrupt_009.phpt
Normal 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===
|
||||
6
ext/phar/tests/zip/files/corrupt3.php.inc
Normal file
6
ext/phar/tests/zip/files/corrupt3.php.inc
Normal 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');
|
||||
?>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
BIN
ext/phar/tests/zip/files/extralen_toolong.zip
Normal file
BIN
ext/phar/tests/zip/files/extralen_toolong.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user