Browse Source

increase code coverage

PECL
Greg Beaver 18 years ago
parent
commit
8526b78286
  1. 17
      ext/phar/tests/zip/corrupt_009.phpt
  2. 6
      ext/phar/tests/zip/files/corrupt3.php.inc
  3. 9
      ext/phar/tests/zip/files/corrupt_zipmaker.php.inc
  4. BIN
      ext/phar/tests/zip/files/extralen_toolong.zip

17
ext/phar/tests/zip/corrupt_009.phpt

@ -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

@ -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');
?>

9
ext/phar/tests/zip/files/corrupt_zipmaker.php.inc

@ -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

Loading…
Cancel
Save