From 09f3c5c7e928baca7e9775e9e135f4d65dad33a7 Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Mon, 22 May 2017 21:45:57 +0300 Subject: [PATCH 1/2] zlib: fix node crashing on invalid options This is a partial backport of semver-patch bits of 9e4660b5187d4be6a1484e705dc735c0e76ffafa. This commit fixes the Node process crashing when constructors of classes of the zlib module are given invalid options. * Throw an Error when the zlib library rejects the value of windowBits, instead of crashing with an assertion. * Treat windowBits and memLevel options consistently with other ones and don't crash when non-numeric values are given. Refs: https://github.com/nodejs/node/pull/13098 --- doc/api/zlib.md | 4 ++++ lib/zlib.js | 10 ++++++++-- src/node_zlib.cc | 13 ++++++++----- test/parallel/test-zlib-failed-init.js | 13 +++++++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 test/parallel/test-zlib-failed-init.js diff --git a/doc/api/zlib.md b/doc/api/zlib.md index d28c411f70f389..7c6b9a32f8ef85 100644 --- a/doc/api/zlib.md +++ b/doc/api/zlib.md @@ -436,6 +436,10 @@ added: v0.5.8 Returns a new [DeflateRaw][] object with an [options][]. +*Note*: The zlib library rejects requests for 256-byte windows (i.e., +`{ windowBits: 8 }` in `options`). An `Error` will be thrown when creating a +[DeflateRaw][] object with this specific value of the `windowBits` option. + ## zlib.createGunzip([options])