From bd65bb67e25a79b019d745b7262b2008ce2adb15 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 16 Nov 2016 01:59:39 +0100 Subject: incrementally verify denoms The denominations are not stored in a separate object store. --- node_modules/adm-zip/zipEntry.js | 72 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 66 insertions(+), 6 deletions(-) (limited to 'node_modules/adm-zip/zipEntry.js') diff --git a/node_modules/adm-zip/zipEntry.js b/node_modules/adm-zip/zipEntry.js index 02c317256..03b57d69f 100644 --- a/node_modules/adm-zip/zipEntry.js +++ b/node_modules/adm-zip/zipEntry.js @@ -34,7 +34,11 @@ module.exports = function (/*Buffer*/input) { return true; } - function decompress(/*Boolean*/async, /*Function*/callback) { + function decompress(/*Boolean*/async, /*Function*/callback, /*String*/pass) { + if(typeof callback === 'undefined' && typeof async === 'string') { + pass=async; + async=void 0; + } if (_isDirectory) { if (async && callback) { callback(new Buffer(0), Utils.Errors.DIRECTORY_CONTENT_ERROR); //si added error. @@ -43,6 +47,7 @@ module.exports = function (/*Buffer*/input) { } var compressedData = getCompressedDataFromZip(); + if (compressedData.length == 0) { if (async && callback) callback(compressedData, Utils.Errors.NO_DATA);//si added error. return compressedData; @@ -73,7 +78,7 @@ module.exports = function (/*Buffer*/input) { } else { inflater.inflateAsync(function(result) { result.copy(data, 0); - if (crc32OK(data)) { + if (!crc32OK(data)) { if (callback) callback(data, Utils.Errors.BAD_CRC); //si added error } else { //si added otherwise did not seem to return data. if (callback) callback(data); @@ -136,6 +141,57 @@ module.exports = function (/*Buffer*/input) { } } + function readUInt64LE(buffer, offset) { + return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset); + } + + function parseExtra(data) { + var offset = 0; + var signature, size, part; + while(offset= Constants.EF_ZIP64_SCOMP) { + size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP); + if(_entryHeader.size === Constants.EF_ZIP64_OR_32) { + _entryHeader.size = size; + } + } + if(data.length >= Constants.EF_ZIP64_RHO) { + compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP); + if(_entryHeader.compressedSize === Constants.EF_ZIP64_OR_32) { + _entryHeader.compressedSize = compressedSize; + } + } + if(data.length >= Constants.EF_ZIP64_DSN) { + offset = readUInt64LE(data, Constants.EF_ZIP64_RHO); + if(_entryHeader.offset === Constants.EF_ZIP64_OR_32) { + _entryHeader.offset = offset; + } + } + if(data.length >= Constants.EF_ZIP64_DSN+4) { + diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN); + if(_entryHeader.diskNumStart === Constants.EF_ZIP64_OR_16) { + _entryHeader.diskNumStart = diskNumStart; + } + } + } + + return { get entryName () { return _entryName.toString(); }, get rawEntryName() { return _entryName; }, @@ -150,6 +206,7 @@ module.exports = function (/*Buffer*/input) { set extra (val) { _extra = val; _entryHeader.extraLength = val.length; + parseExtra(val); }, get comment () { return _comment.toString(); }, @@ -180,14 +237,17 @@ module.exports = function (/*Buffer*/input) { } }, - getData : function() { - return decompress(false, null); + getData : function(pass) { + return decompress(false, null, pass); }, - getDataAsync : function(/*Function*/callback) { - decompress(true, callback) + getDataAsync : function(/*Function*/callback, pass) { + decompress(true, callback, pass) }, + set attr(attr) { _entryHeader.attr = attr; }, + get attr() { return _entryHeader.attr; }, + set header(/*Buffer*/data) { _entryHeader.loadFromBinary(data); }, -- cgit v1.2.3