From 2a0bb196c0e22ac950106b81ae0e96dd335f3817 Mon Sep 17 00:00:00 2001 From: DonBrinn Date: Wed, 13 Dec 2023 15:46:59 -0500 Subject: [PATCH] Always set 4-byte file offset field to 0xFFFFFFFF in header when including file offset in central diretory extra fields --- lib/archivers/zip/zip-archive-output-stream.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/archivers/zip/zip-archive-output-stream.js b/lib/archivers/zip/zip-archive-output-stream.js index 9e04922b..f56cea93 100644 --- a/lib/archivers/zip/zip-archive-output-stream.js +++ b/lib/archivers/zip/zip-archive-output-stream.js @@ -263,14 +263,15 @@ ZipArchiveOutputStream.prototype._writeCentralDirectoryZip64 = function() { ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) { var gpb = ae.getGeneralPurposeBit(); var method = ae.getMethod(); - var offsets = ae._offsets; + var fileOffset = ae._offsets.file; var size = ae.getSize(); var compressedSize = ae.getCompressedSize(); - if (ae.isZip64() || offsets.file > constants.ZIP64_MAGIC) { + if (ae.isZip64() || fileOffset > constants.ZIP64_MAGIC) { size = constants.ZIP64_MAGIC; compressedSize = constants.ZIP64_MAGIC; + fileOffset = constants.ZIP64_MAGIC; ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64); @@ -279,7 +280,7 @@ ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) { zipUtil.getShortBytes(24), zipUtil.getEightBytes(ae.getSize()), zipUtil.getEightBytes(ae.getCompressedSize()), - zipUtil.getEightBytes(offsets.file) + zipUtil.getEightBytes(ae._offsets.file) ], 28); ae.setExtra(extraBuf); @@ -336,11 +337,7 @@ ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) { this.write(zipUtil.getLongBytes(ae.getExternalAttributes())); // relative offset of LFH - if (offsets.file > constants.ZIP64_MAGIC) { - this.write(zipUtil.getLongBytes(constants.ZIP64_MAGIC)); - } else { - this.write(zipUtil.getLongBytes(offsets.file)); - } + this.write(zipUtil.getLongBytes(fileOffset)); // name this.write(name);