--- /dev/null
+--TEST--
+Phar: corrupted zip (central directory offset incorrect)
+--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/cdir_offset.zip');
+} catch (Exception $e) {
+ echo $e->getMessage() . "\n";
+}
+?>
+===DONE===
+--EXPECTF--
+phar error: corrupted central directory entry, no magic signature in zip-based phar "%scdir_offset.zip"
+===DONE===
$a->writeZip(dirname(__FILE__) . '/count2.zip', 'count2');
$a->writeZip(dirname(__FILE__) . '/nozipend.zip', 'none');
$a->writeZip(dirname(__FILE__) . '/filecomment.zip', 'comment');
+$a->writeZip(dirname(__FILE__) . '/cdir_offset.zip', 'cdir_offset');
?>
$this->offset, strlen($this->start),
strlen($this->comment)) . $this->comment;
break;
- case 'cdir_len' :
+ case 'cdir_offset' :
$write .= "PK\x05\x06\x00\x00\x00\x00" .
pack("vvVVv", $this->count, $this->count,
$this->offset, strlen($this->start) - 3,
strlen($this->comment)) . $this->comment;
break;
- case 'cdir_offset' :
+ case 'cdir_len' :
$write .= "PK\x05\x06\x00\x00\x00\x00" .
pack("vvVVv", $this->count, $this->count,
- $this->offset + 1, strlen($this->start),
+ $this->offset - 5, strlen($this->start),
strlen($this->comment)) . $this->comment;
break;
case 'comment' :