FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

(v6.x backport) zlib: fix node crashing on invalid options by aqrln · Pull Request #13201 · nodejs/node · GitHub

/ node Public

(v6.x backport) zlib: fix node crashing on invalid options - #13201

Closed
aqrln wants to merge 2 commits into
nodejs:v6.x-stagingfrom
aqrln:v6.x-backport-13098
Closed

(v6.x backport) zlib: fix node crashing on invalid options#13201
aqrln wants to merge 2 commits into
nodejs:v6.x-stagingfrom
aqrln:v6.x-backport-13098

Conversation

aqrln commented May 24, 2017

Copy link
Copy Markdown
Contributor

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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

zlib

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
nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. v6.x zlib Issues and PRs related to the zlib subsystem. labels May 24, 2017
aqrln changed the title zlib: fix node crashing on invalid options (v6.x backport) zlib: fix node crashing on invalid options May 24, 2017
Comment thread src/node_zlib.cc
ctx->init_done_ = true;

if (ctx->err_ != Z_OK) {
if (dictionary != nullptr) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fwiw, you don't need the conditional, the following two lines of code can run correctly whether dictionary is nullptr or not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Oh, nice. Thanks.

refack left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM % small nits

Comment thread 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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

If your changing this line anyway, IMHO handle the fallback in 383 (opts.windowBits && typeof...)

Comment thread lib/zlib.js Outdated
this._handle.init(windowBits || exports.Z_DEFAULT_WINDOWBITS,
level,
opts.memLevel || exports.Z_DEFAULT_MEMLEVEL,
memLevel || exports.Z_DEFAULT_MEMLEVEL,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ditto


// For raw deflate encoding, requests for 256-byte windows are rejected as
// invalid by zlib.
// (http://zlib.net/manual.html#Advanced)

refack May 25, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

change to:
Ref: http://zlib.net/manual.html#Advanced

Dismissed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Not a good idea to change this one since that's how it is already committed to master.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ack.

refack left a comment
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Win! 💯
(appreciated all the branch juggling you did for that)

aqrln commented May 25, 2017

Copy link
Copy Markdown
Contributor Author

Copy link
Copy Markdown
Contributor

This can land once we do the next v6.x release

gibfahn commented Jun 17, 2017

Copy link
Copy Markdown
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>

gibfahn commented Jun 17, 2017

Copy link
Copy Markdown
Member

Landed in 321c90f

gibfahn closed this Jun 17, 2017
aqrln deleted the v6.x-backport-13098 branch June 18, 2017 09:47
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>

addaleax commented Aug 7, 2017

Copy link
Copy Markdown
Member

This should probably be released together with #14666

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

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. zlib Issues and PRs related to the zlib subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL