From bf63a37f832fd81ccabd970c48f5842c497d47ca Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Thu, 18 May 2017 18:53:35 +0300 Subject: [PATCH] squash! check windowsBits === 8 early --- lib/zlib.js | 4 ++++ ...ed-init.js => test-zlib-deflate-unsupported-windowbits.js} | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) rename test/parallel/{test-zlib-failed-init.js => test-zlib-deflate-unsupported-windowbits.js} (83%) diff --git a/lib/zlib.js b/lib/zlib.js index 1b20e160052097..804e0acc3ddf32 100644 --- a/lib/zlib.js +++ b/lib/zlib.js @@ -193,6 +193,10 @@ class Zlib extends Transform { opts.windowBits > constants.Z_MAX_WINDOWBITS) { throw new RangeError('Invalid windowBits: ' + opts.windowBits); } + if (mode === constants.DEFLATERAW && + opts.windowBits === 8) { + throw new RangeError('Unsupported windowBits for DeflateRaw: 8'); + } } if (opts.level) { diff --git a/test/parallel/test-zlib-failed-init.js b/test/parallel/test-zlib-deflate-unsupported-windowbits.js similarity index 83% rename from test/parallel/test-zlib-failed-init.js rename to test/parallel/test-zlib-deflate-unsupported-windowbits.js index afc2c82ddfca8e..96d95aca71c688 100644 --- a/test/parallel/test-zlib-failed-init.js +++ b/test/parallel/test-zlib-deflate-unsupported-windowbits.js @@ -10,4 +10,4 @@ const zlib = require('zlib'); // (http://zlib.net/manual.html#Advanced) assert.throws(() => { zlib.createDeflateRaw({ windowBits: 8 }); -}, /^Error: Init error$/); +}, /^RangeError: Unsupported windowBits for DeflateRaw: 8$/);