From 2a938824982848b0a075fefba6b6e888477fb3a8 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 3 Nov 2018 11:24:50 -0400 Subject: [PATCH] src: fix Get() usage in tls_wrap.cc PR-URL: https://github.com/nodejs/node/pull/24060 Reviewed-By: Daniel Bevenius Reviewed-By: Anna Henningsen Reviewed-By: Joyee Cheung --- src/tls_wrap.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc index 6bc152b2e24fca..1d982db28e2558 100644 --- a/src/tls_wrap.cc +++ b/src/tls_wrap.cc @@ -213,17 +213,22 @@ void TLSWrap::SSLInfoCallback(const SSL* ssl_, int where, int ret) { Local object = c->object(); if (where & SSL_CB_HANDSHAKE_START) { - Local callback = object->Get(env->onhandshakestart_string()); - if (callback->IsFunction()) { + Local callback; + + if (object->Get(env->context(), env->onhandshakestart_string()) + .ToLocal(&callback) && callback->IsFunction()) { Local argv[] = { env->GetNow() }; c->MakeCallback(callback.As(), arraysize(argv), argv); } } if (where & SSL_CB_HANDSHAKE_DONE) { + Local callback; + c->established_ = true; - Local callback = object->Get(env->onhandshakedone_string()); - if (callback->IsFunction()) { + + if (object->Get(env->context(), env->onhandshakedone_string()) + .ToLocal(&callback) && callback->IsFunction()) { c->MakeCallback(callback.As(), 0, nullptr); } } @@ -814,7 +819,10 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) { // Call the SNI callback and use its return value as context Local object = p->object(); - Local ctx = object->Get(env->sni_context_string()); + Local ctx; + + if (!object->Get(env->context(), env->sni_context_string()).ToLocal(&ctx)) + return SSL_TLSEXT_ERR_NOACK; // Not an object, probably undefined or null if (!ctx->IsObject())