-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Conversation
src/node_crypto.cc
Outdated
@@ -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(); |
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.
actually, indentation nit: 4 spaces ;)
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.
Thanks, done :)
src/node_crypto.cc
Outdated
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()); |
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.
Any reason not to call .FromJust()
here and below as well (à la RandomBytesBuffer()
)?
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.
I added checks to the result of Set()
:)
This could likely benefit from a test. |
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]>
Landed in 1c36243.
@jasnell I considered adding one, but I was unable to cause a segmentation fault from JavaScript without using an undocumented internal API ( CI on master: https://ci.nodejs.org/job/node-test-commit-linuxone/7699/ |
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]>
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 |
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), orvcbuild test
(Windows) passesAffected core subsystem(s)
crypto