-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
zlib: fix node crashing on invalid options #13098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
7d78533
c5440af
c5f18b1
e5c39bd
7b39725
f91e191
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,9 +229,15 @@ class Zlib extends Transform { | |
| var strategy = constants.Z_DEFAULT_STRATEGY; | ||
| if (typeof opts.strategy === 'number') strategy = opts.strategy; | ||
|
|
||
| this._handle.init(opts.windowBits || constants.Z_DEFAULT_WINDOWBITS, | ||
| var windowBits = constants.Z_DEFAULT_WINDOWBITS; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Couldn't these both just be ternaries?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They could, and I'd like them to be, but I just wrote these in a style consistent with the code above. How about me addressing this comment in a follow-up PR, together with some more refactoring like replacing most
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure |
||
| if (typeof opts.windowBits === 'number') windowBits = opts.windowBits; | ||
|
|
||
| var memLevel = constants.Z_DEFAULT_MEMLEVEL; | ||
| if (typeof opts.memLevel === 'number') memLevel = opts.memLevel; | ||
|
||
|
|
||
| this._handle.init(windowBits, | ||
| level, | ||
| opts.memLevel || constants.Z_DEFAULT_MEMLEVEL, | ||
| memLevel, | ||
| strategy, | ||
| opts.dictionary); | ||
|
|
||
|
|
||
| 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 }); | ||
| }, /Init error/); | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe start the note with "The"