Skip to content

Commit 51c1afa

Browse files
tniessenaddaleax
authored andcommitted
crypto: change segmentation faults to CHECKs
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]>
1 parent 87e1080 commit 51c1afa

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/node_crypto.cc

+16-5
Original file line numberDiff line numberDiff line change
@@ -5424,8 +5424,13 @@ void PBKDF2(const FunctionCallbackInfo<Value>& args) {
54245424
if (args[5]->IsFunction()) {
54255425
obj->Set(env->ondone_string(), args[5]);
54265426

5427-
if (env->in_domain())
5428-
obj->Set(env->domain_string(), env->domain_array()->Get(0));
5427+
if (env->in_domain()) {
5428+
obj->Set(env->context(),
5429+
env->domain_string(),
5430+
env->domain_array()->Get(env->context(), 0).ToLocalChecked())
5431+
.FromJust();
5432+
}
5433+
54295434
uv_queue_work(env->event_loop(),
54305435
req->work_req(),
54315436
PBKDF2Request::Work,
@@ -5627,8 +5632,13 @@ void RandomBytes(const FunctionCallbackInfo<Value>& args) {
56275632
if (args[1]->IsFunction()) {
56285633
obj->Set(env->ondone_string(), args[1]);
56295634

5630-
if (env->in_domain())
5631-
obj->Set(env->domain_string(), env->domain_array()->Get(0));
5635+
if (env->in_domain()) {
5636+
obj->Set(env->context(),
5637+
env->domain_string(),
5638+
env->domain_array()->Get(env->context(), 0).ToLocalChecked())
5639+
.FromJust();
5640+
}
5641+
56325642
uv_queue_work(env->event_loop(),
56335643
req->work_req(),
56345644
RandomBytesWork,
@@ -5673,7 +5683,8 @@ void RandomBytesBuffer(const FunctionCallbackInfo<Value>& args) {
56735683
if (env->in_domain()) {
56745684
obj->Set(env->context(),
56755685
env->domain_string(),
5676-
env->domain_array()->Get(0)).FromJust();
5686+
env->domain_array()->Get(env->context(), 0).ToLocalChecked())
5687+
.FromJust();
56775688
}
56785689

56795690
uv_queue_work(env->event_loop(),

0 commit comments

Comments
 (0)