(v6.x backport) zlib: fix node crashing on invalid options#13201
Closed
aqrln wants to merge 2 commits intonodejs:v6.x-stagingfrom
Closed
(v6.x backport) zlib: fix node crashing on invalid options#13201aqrln wants to merge 2 commits intonodejs:v6.x-stagingfrom
aqrln wants to merge 2 commits intonodejs:v6.x-stagingfrom
Conversation
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. Refs: nodejs#13098
sam-github
reviewed
May 24, 2017
| ctx->init_done_ = true; | ||
|
|
||
| if (ctx->err_ != Z_OK) { | ||
| if (dictionary != nullptr) { |
Contributor
There was a problem hiding this comment.
fwiw, you don't need the conditional, the following two lines of code can run correctly whether dictionary is nullptr or not.
sam-github
approved these changes
May 24, 2017
refack
approved these changes
May 25, 2017
lib/zlib.js
Outdated
| var memLevel = exports.Z_DEFAULT_MEMLEVEL; | ||
| if (typeof opts.memLevel === 'number') memLevel = opts.memLevel; | ||
|
|
||
| this._handle.init(windowBits || exports.Z_DEFAULT_WINDOWBITS, |
Contributor
There was a problem hiding this comment.
If your changing this line anyway, IMHO handle the fallback in 383 (opts.windowBits && typeof...)
lib/zlib.js
Outdated
| this._handle.init(windowBits || exports.Z_DEFAULT_WINDOWBITS, | ||
| level, | ||
| opts.memLevel || exports.Z_DEFAULT_MEMLEVEL, | ||
| memLevel || exports.Z_DEFAULT_MEMLEVEL, |
|
|
||
| // For raw deflate encoding, requests for 256-byte windows are rejected as | ||
| // invalid by zlib. | ||
| // (http://zlib.net/manual.html#Advanced) |
Contributor
There was a problem hiding this comment.
change to:
Ref: http://zlib.net/manual.html#Advanced
Dismissed
Contributor
Author
There was a problem hiding this comment.
Not a good idea to change this one since that's how it is already committed to master.
refack
approved these changes
May 25, 2017
Contributor
Author
lpinca
approved these changes
May 25, 2017
jasnell
approved these changes
May 25, 2017
Contributor
|
This can land once we do the next v6.x release |
Member
gibfahn
pushed a commit
to gibfahn/node
that referenced
this pull request
Jun 17, 2017
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: nodejs#13098 Backport-PR-URL: nodejs#13201 Fixes: nodejs#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>
Member
|
Landed in 321c90f |
gibfahn
pushed a commit
that referenced
this pull request
Jun 20, 2017
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>
MylesBorins
pushed a commit
that referenced
this pull request
Jul 11, 2017
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>
Member
|
This should probably be released together with #14666 |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Refs: #13098
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
zlib