Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
Fixing >4GB files not correctly detecting 64bit CDR offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Nik Barham committed Jan 25, 2016
1 parent d565d35 commit 875f833
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions src/ZipStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*/
class ZipStream {
const VERSION = '0.1.0';
const ZIP_VERSION = 0x000A;
const ZIP_VERSION = 0x002D;

const METHOD_STORE = 0x00;
const METHOD_DEFLATE = 0x08;
Expand Down Expand Up @@ -846,16 +846,32 @@ protected function addCdrEof($opt = null) {
$comment = $opt['comment'];
}

$fields = [
['V', static::CDR_EOF_SIGNATURE], // end of central file header signature
['v', 0x00], // disk number
['v', 0x00], // no of disks
['v', $num], // no of entries on disk
['v', $num], // no of entries in cdr
['V', $cdr_len], // CDR size
['V', $cdr_ofs], // CDR offset
['v', strlen($comment)], // Zip Comment size
];
if ($this->opt[static::OPTION_USE_ZIP64])
{
$fields = [
['V', static::CDR_EOF_SIGNATURE], // end of central file header signature
['v', 0x00], // disk number
['v', 0x00], // no of disks
['v', $num], // no of entries on disk
['v', $num], // no of entries in cdr
['V', 0xFFFFFFFF], // CDR size (Force to 0xFFFFFFFF for Zip64)
['V', 0xFFFFFFFF], // CDR offset (Force to 0xFFFFFFFF for Zip64)
['v', strlen($comment)], // Zip Comment size
];
}
else
{
$fields = [
['V', static::CDR_EOF_SIGNATURE], // end of central file header signature
['v', 0x00], // disk number
['v', 0x00], // no of disks
['v', $num], // no of entries on disk
['v', $num], // no of entries in cdr
['V', $cdr_len], // CDR size
['V', $cdr_ofs], // CDR offset
['v', strlen($comment)], // Zip Comment size
];
}

$ret = $this->packFields($fields) . $comment;
$this->send($ret);
Expand Down

0 comments on commit 875f833

Please sign in to comment.