Skip to content

Commit 502555a

Browse files
cjihrigBethGriggs
authored andcommitted
src: fix Get() usage in tls_wrap.cc
Backport-PR-URL: #27967 PR-URL: #24060 Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]>
1 parent 6b0d202 commit 502555a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/tls_wrap.cc

+13-5
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,10 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) {
221221
Local<Object> object = c->object();
222222

223223
if (where & SSL_CB_HANDSHAKE_START) {
224-
Local<Value> callback = object->Get(env->onhandshakestart_string());
225-
if (callback->IsFunction()) {
224+
Local<Value> callback;
225+
226+
if (object->Get(env->context(), env->onhandshakestart_string())
227+
.ToLocal(&callback) && callback->IsFunction()) {
226228
Local<Value> argv[] = { env->GetNow() };
227229
c->MakeCallback(callback.As<Function>(), arraysize(argv), argv);
228230
}
@@ -232,9 +234,12 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) {
232234
// sending HelloRequest in OpenSSL-1.1.1.
233235
// We need to check whether this is in a renegotiation state or not.
234236
if (where & SSL_CB_HANDSHAKE_DONE && !SSL_renegotiate_pending(ssl)) {
237+
Local<Value> callback;
238+
235239
c->established_ = true;
236-
Local<Value> callback = object->Get(env->onhandshakedone_string());
237-
if (callback->IsFunction()) {
240+
241+
if (object->Get(env->context(), env->onhandshakedone_string())
242+
.ToLocal(&callback) && callback->IsFunction()) {
238243
c->MakeCallback(callback.As<Function>(), 0, nullptr);
239244
}
240245
}
@@ -845,7 +850,10 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {
845850

846851
// Call the SNI callback and use its return value as context
847852
Local<Object> object = p->object();
848-
Local<Value> ctx = object->Get(env->sni_context_string());
853+
Local<Value> ctx;
854+
855+
if (!object->Get(env->context(), env->sni_context_string()).ToLocal(&ctx))
856+
return SSL_TLSEXT_ERR_NOACK;
849857

850858
// Not an object, probably undefined or null
851859
if (!ctx->IsObject())

0 commit comments

Comments
 (0)