Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
crypto: add check for funciton call fail scenario, add test case for …
…the fix
  • Loading branch information
ThakurKarthik committed Sep 30, 2020
commit e8edcb52fac6fb070a8c8fb84f7246666dfc7acb
4 changes: 3 additions & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3467,7 +3467,9 @@ BaseObjectPtr<BaseObject> NativeKeyObject::KeyObjectTransferData::Deserialize(
Local<Function> key_ctor;
Local<Value> arg = FIXED_ONE_BYTE_STRING(env->isolate(),
"internal/crypto/keys");
env->native_module_require()->Call(context, Null(env->isolate()), 1, &arg);
if (env->native_module_require()->
Call(context, Null(env->isolate()), 1, &arg).IsEmpty())
return {};
switch (data_->GetKeyType()) {
case kKeyTypeSecret:
key_ctor = env->crypto_key_object_secret_constructor();
Expand Down
18 changes: 18 additions & 0 deletions test/parallel/test-crypto-worker-thread.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

// Issue https://github.com/nodejs/node/issues/35263
/* Description: test for checking keyobject passed to worker thread
does not crash */
const { createSecretKey } = require('crypto');

const { Worker, isMainThread, workerData } = require('worker_threads');

if (isMainThread) {
const key = createSecretKey(Buffer.from('hello'));
new Worker(__filename, { workerData: key });
} else {
console.log(workerData);
}