Skip to content
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

crypto: change segmentation faults to CHECKs #14548

Closed
wants to merge 3 commits into from

Conversation

tniessen
Copy link
Member

Fixes: #14519

I intentionally did not fix this in cares_wrap.cc as @addaleax already did that in #14518 (assuming it gets merged).

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

crypto

@tniessen tniessen added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Jul 30, 2017
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Jul 30, 2017
@tniessen
Copy link
Member Author

@tniessen tniessen self-assigned this Jul 30, 2017
@@ -5673,7 +5679,8 @@ void RandomBytesBuffer(const FunctionCallbackInfo<Value>& args) {
if (env->in_domain()) {
obj->Set(env->context(),
env->domain_string(),
env->domain_array()->Get(0)).FromJust();
env->domain_array()->Get(env->context(), 0).ToLocalChecked())
.FromJust();
Copy link
Member

Choose a reason for hiding this comment

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

actually, indentation nit: 4 spaces ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, done :)

obj->Set(env->domain_string(), env->domain_array()->Get(0));
if (env->in_domain()) {
obj->Set(env->domain_string(),
env->domain_array()->Get(env->context(), 0).ToLocalChecked());
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to call .FromJust() here and below as well (à la RandomBytesBuffer())?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added checks to the result of Set() :)

@tniessen
Copy link
Member Author

@jasnell
Copy link
Member

jasnell commented Jul 31, 2017

This could likely benefit from a test.

tniessen added a commit that referenced this pull request Aug 2, 2017
PR-URL: #14548
Fixes: #14519
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@tniessen
Copy link
Member Author

tniessen commented Aug 2, 2017

Landed in 1c36243.

This could likely benefit from a test.

@jasnell I considered adding one, but I was unable to cause a segmentation fault from JavaScript without using an undocumented internal API (process._setupDomainUse) in a very hackish way, and I didn't think it was a good idea to write a test revolving around that.

CI on master: https://ci.nodejs.org/job/node-test-commit-linuxone/7699/

@tniessen tniessen closed this Aug 2, 2017
addaleax pushed a commit that referenced this pull request Aug 2, 2017
PR-URL: #14548
Fixes: #14519
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Timothy Gu <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@addaleax addaleax mentioned this pull request Aug 2, 2017
@MylesBorins
Copy link
Contributor

This does not land cleanly in LTS. Please feel free to manually backport by following the guide. Please also feel free to replace do-not-land if it is being backported

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++. crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal domain function can be used to cause segfaults
7 participants