Skip to content

Commit

Permalink
crypto: change segmentation faults to CHECKs
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tniessen committed Aug 2, 2017
1 parent 8a8a686 commit 1c36243
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5424,8 +5424,13 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
if (args[5]->IsFunction()) {
obj->Set(env->ondone_string(), args[5]);

if (env->in_domain())
obj->Set(env->domain_string(), env->domain_array()->Get(0));
if (env->in_domain()) {
obj->Set(env->context(),
env->domain_string(),
env->domain_array()->Get(env->context(), 0).ToLocalChecked())
.FromJust();
}

uv_queue_work(env->event_loop(),
req->work_req(),
PBKDF2Request::Work,
Expand Down Expand Up @@ -5627,8 +5632,13 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) {
if (args[1]->IsFunction()) {
obj->Set(env->ondone_string(), args[1]);

if (env->in_domain())
obj->Set(env->domain_string(), env->domain_array()->Get(0));
if (env->in_domain()) {
obj->Set(env->context(),
env->domain_string(),
env->domain_array()->Get(env->context(), 0).ToLocalChecked())
.FromJust();
}

uv_queue_work(env->event_loop(),
req->work_req(),
RandomBytesWork,
Expand Down Expand Up @@ -5673,7 +5683,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();
}

uv_queue_work(env->event_loop(),
Expand Down

0 comments on commit 1c36243

Please sign in to comment.