kevva / decompress

Extracting archives made easy
MIT License
415 stars 51 forks source link

Exception RangeError: out of range index #61

Open gitowiec opened 7 years ago

gitowiec commented 7 years ago

I got error using decompress on AWS Lambda here is a stack trace when trying to unzip a file, AWS Lambda runs using Node 6.10.

at RangeError (native)
at BufferSlicer.read (/var/task/src/handler.js:13590:16)
at readAndAssertNoEof (/var/task/src/handler.js:35297:11)
at ZipFile.readEntry (/var/task/src/handler.js:34927:4)
at Promise (/var/task/src/handler.js:12198:7)
at extractFile (/var/task/src/handler.js:12195:29)

Here is the source of the function where line 35297 is for this.buffer.copy

    BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
      var end = position + length;
      var delta = end - this.buffer.length;
      var written = (delta > 0) ? delta : length;
      this.buffer.copy(buffer, offset, position, end);
      setImmediate(function() {
        callback(null, written);
      });
    };