From 12d0bc6e3a6f576111dc21d03afeb59af571bbe0 Mon Sep 17 00:00:00 2001 From: Josh Wolfe Date: Sun, 3 Jun 2018 18:55:42 -0400 Subject: [PATCH] fromBuffer limits maxChunkSize. closes #87 --- README.md | 3 ++- index.js | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 190f549..cc5a0c2 100644 --- a/README.md +++ b/README.md @@ -594,8 +594,9 @@ This library makes no attempt to interpret the Language Encoding Flag. ## Change History - * 2.10.0 + * 2.9.2 * Removed `tools/hexdump-zip.js` and `tools/hex2bin.js`. Those tools are now located here: [thejoshwolfe/hexdump-zip](https://github.com/thejoshwolfe/hexdump-zip) and [thejoshwolfe/hex2bin](https://github.com/thejoshwolfe/hex2bin) + * Worked around performance problem with zlib when using `fromBuffer()` and `readStream.destroy()` for large compressed files. [issue #87](https://github.com/thejoshwolfe/yauzl/issues/87) * 2.9.1 * Removed `console.log()` accidentally introduced in 2.9.0. [issue #64](https://github.com/thejoshwolfe/yauzl/issues/64) * 2.9.0 diff --git a/index.js b/index.js index 4681cf2..780633b 100644 --- a/index.js +++ b/index.js @@ -66,8 +66,8 @@ function fromBuffer(buffer, options, callback) { if (options.lazyEntries == null) options.lazyEntries = false; if (options.decodeStrings == null) options.decodeStrings = true; if (options.validateEntrySizes == null) options.validateEntrySizes = true; - // i got your open file right here. - var reader = fd_slicer.createFromBuffer(buffer); + // limit the max chunk size. see https://github.com/thejoshwolfe/yauzl/issues/87 + var reader = fd_slicer.createFromBuffer(buffer, {maxChunkSize: 0x10000}); fromRandomAccessReader(reader, buffer.length, options, callback); } diff --git a/package.json b/package.json index 800621d..0c011e0 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ }, "homepage": "https://github.com/thejoshwolfe/yauzl", "dependencies": { - "fd-slicer": "~1.0.1", + "fd-slicer": "~1.1.0", "buffer-crc32": "~0.2.3" }, "devDependencies": {