Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
6c81b75
deps: add example of comparing OpenSSL changes
danbev May 26, 2017
d319015
deps: upgrade openssl sources to 1.0.2l
danbev May 26, 2017
b0b52bc
deps: copy all openssl header files to include dir
danbev May 26, 2017
22d74c4
deps: fix openssl assembly error on ia32 win32
indutny Jan 8, 2014
32bbf7a
deps: fix asm build error of openssl in x86_win32
Feb 13, 2015
b7a80dd
openssl: fix keypress requirement in apps on win32
Feb 17, 2015
f90919f
deps: add -no_rand_screen to openssl s_client
May 27, 2015
02a04cf
deps: update openssl config files
danbev May 26, 2017
99cadcb
deps: update openssl asm and asm_obsolete files
danbev Jun 1, 2017
e510003
doc: add missing make command to UPGRADING.md
danbev May 30, 2017
6602954
doc: consistent case for primitive types
silverwind Feb 4, 2017
40babf1
doc: linkify type[] syntax, support lowercase for primitives
silverwind Feb 14, 2017
e70cb6a
tools: fix lint issue in doctool
silverwind Mar 2, 2017
311ef42
doc/tools: fix more type inconsistencies
silverwind Mar 5, 2017
ae20511
test: enable setuid/setgid test
Trott Apr 13, 2017
4848862
test: introduce `common.crashOnUnhandledRejection`
addaleax Apr 19, 2017
dfcefd6
test,doc: document `crashOnUnhandledRejection()`
addaleax Apr 27, 2017
321c90f
zlib: fix node crashing on invalid options
aqrln May 22, 2017
04fb72f
crypto: clear err stack after ECDH::BufferToPoint
rfk May 29, 2017
11c7e01
v8: fix build errors with g++ 7
Jun 9, 2017
099694f
test: move test-debug-brk to sequential
gibfahn Jun 9, 2017
7a22964
test: move common.PORT debug tests to sequential
gibfahn Jun 10, 2017
7da19db
doc: update output examples in debugger.md
vsemozhetbyt Jun 17, 2017
b2d59b1
benchmark: add final clean-up to module-loader.js
vsemozhetbyt Mar 19, 2017
7af83ff
test: add internal/socket_list tests
davidtaikocha Mar 29, 2017
beb1644
doc: argument types for https methods
ameliavoncat Mar 3, 2017
6f86285
doc: minor improvements in BUILDING.md
thefourtheye Apr 1, 2017
f7abf36
test: add basic cctest for base64.h
aqrln Apr 5, 2017
cde1e9d
tools: replace custom new-with-error rule
Trott Apr 6, 2017
ba51c18
test: remove disabled tls_server.js
Trott Apr 7, 2017
7093711
tools: replace custom assert.fail lint rule
Trott Apr 9, 2017
6d0c4ed
build: clear stalled jobs on POSIX CI hosts
Trott Feb 8, 2017
6d7795f
doc: update os.uptime() and process.uptime() info
vsemozhetbyt Apr 9, 2017
163b3cb
src: remove superfluous env_string string
bnoordhuis Oct 20, 2016
fa9d6ad
src: make cross-context MakeCallback() calls work
bnoordhuis Oct 21, 2016
e3dacbf
test: remove disabled test-dgram-send-error
Trott Apr 11, 2017
01cb518
build: avoid passing kill empty input in Makefile
gibfahn Apr 1, 2017
f359682
test: run the addon tests last
seppevs Mar 27, 2017
ff637f1
build: disable -O3 for C++ coverage
addaleax Apr 13, 2017
ef1afdc
benchmark,windows: TCP.readStart() meaningful only after completion
refack Apr 6, 2017
cff0043
test: replace [].join() with ''.repeat()
JacksonTian Apr 10, 2017
6578884
test: remove common.PORT from multiple tests
tarunbatra Apr 16, 2017
5a86259
test: fix coverity UNINIT_CTOR cctest warning
bnoordhuis Apr 13, 2017
8fdc978
test: dynamic port in cluster worker wait close
Apr 17, 2017
c2afcea
repl: support hidden history file on Windows
bzoz Apr 20, 2017
7714f97
repl: fix /dev/null history file regression
mscdex Apr 30, 2017
03f8ffe
doc: modernize and fix code examples in repl.md
vsemozhetbyt Apr 24, 2017
172cbfc
test: dynamic port in parallel regress tests
Apr 26, 2017
17cb9ca
test: replace indexOf with includes
gwer Apr 22, 2017
cdd5b52
tools: ignore node_trace.*.log
watilde May 2, 2017
2532fb4
stream: remove unnecessary parameter
Aug 17, 2016
f607d85
build: add static option to vcbuild.bat
Apr 30, 2017
c4c7e9b
test,lib,doc: use function declarations
Trott Apr 28, 2017
35cc20b
tools: require function declarations
Trott Apr 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
zlib: fix node crashing on invalid options
This is a partial backport of semver-patch bits of
9e4660b.

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.

PR-URL: #13098
Backport-PR-URL: #13201
Fixes: #13082
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
aqrln authored and gibfahn committed Jun 17, 2017
commit 321c90f1c96ecad671768b1712178c366c5b5d2c
4 changes: 4 additions & 0 deletions doc/api/zlib.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,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])
<!-- YAML
added: v0.5.8
Expand Down
14 changes: 12 additions & 2 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,19 @@ function Zlib(opts, mode) {
var strategy = exports.Z_DEFAULT_STRATEGY;
if (typeof opts.strategy === 'number') strategy = opts.strategy;

this._handle.init(opts.windowBits || exports.Z_DEFAULT_WINDOWBITS,
var windowBits = exports.Z_DEFAULT_WINDOWBITS;
if (opts.windowBits && typeof opts.windowBits === 'number') {
windowBits = opts.windowBits;
}

var memLevel = exports.Z_DEFAULT_MEMLEVEL;
if (opts.memLevel && typeof opts.memLevel === 'number') {
memLevel = opts.memLevel;
}

this._handle.init(windowBits,
level,
opts.memLevel || exports.Z_DEFAULT_MEMLEVEL,
memLevel,
strategy,
opts.dictionary);

Expand Down
13 changes: 8 additions & 5 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -530,16 +530,19 @@ class ZCtx : public AsyncWrap {
CHECK(0 && "wtf?");
}

if (ctx->err_ != Z_OK) {
ZCtx::Error(ctx, "Init error");
}


ctx->dictionary_ = reinterpret_cast<Bytef *>(dictionary);
ctx->dictionary_len_ = dictionary_len;

ctx->write_in_progress_ = false;
ctx->init_done_ = true;

if (ctx->err_ != Z_OK) {
if (dictionary != nullptr) {
delete[] dictionary;
ctx->dictionary_ = nullptr;
}
ctx->env()->ThrowError("Init error");
}
}

static void SetDictionary(ZCtx* ctx) {
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-zlib-failed-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

require('../common');

const assert = require('assert');
const zlib = require('zlib');

// For raw deflate encoding, requests for 256-byte windows are rejected as
// invalid by zlib.
// (http://zlib.net/manual.html#Advanced)
assert.throws(() => {
zlib.createDeflateRaw({ windowBits: 8 });
}, /^Error: Init error$/);