From d4ad5d1151d787f0c91e1662c9ef224d6e753901 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 12 Aug 2013 23:47:04 +0200 Subject: [PATCH] crypto: use consistent conn object unwrapping We use `Foo:Unwrap(args.This())` everywhere else, let's use the same idiom for Connection::Unwrap(). --- src/node_crypto.cc | 44 ++++++++++++++++++++++---------------------- src/node_crypto.h | 4 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 2d79dac..a2779ed 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1282,7 +1282,7 @@ void Connection::SSLInfoCallback(const SSL *ssl_, int where, int ret) { void Connection::EncIn(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1332,7 +1332,7 @@ void Connection::EncIn(const FunctionCallbackInfo& args) { void Connection::ClearOut(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1386,7 +1386,7 @@ void Connection::ClearOut(const FunctionCallbackInfo& args) { void Connection::ClearPending(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); int bytes_pending = BIO_pending(conn->bio_read_); args.GetReturnValue().Set(bytes_pending); } @@ -1394,7 +1394,7 @@ void Connection::ClearPending(const FunctionCallbackInfo& args) { void Connection::EncPending(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); int bytes_pending = BIO_pending(conn->bio_write_); args.GetReturnValue().Set(bytes_pending); } @@ -1403,7 +1403,7 @@ void Connection::EncPending(const FunctionCallbackInfo& args) { void Connection::EncOut(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1434,7 +1434,7 @@ void Connection::EncOut(const FunctionCallbackInfo& args) { void Connection::ClearIn(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (args.Length() < 3) { return ThrowTypeError("Takes 3 parameters"); @@ -1489,7 +1489,7 @@ void Connection::ClearIn(const FunctionCallbackInfo& args) { void Connection::GetPeerCertificate(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (conn->ssl_ == NULL) return; Local info = Object::New(); @@ -1616,7 +1616,7 @@ void Connection::GetPeerCertificate(const FunctionCallbackInfo& args) { void Connection::GetSession(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (conn->ssl_ == NULL) return; @@ -1637,7 +1637,7 @@ void Connection::GetSession(const FunctionCallbackInfo& args) { void Connection::SetSession(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (args.Length() < 1 || (!args[0]->IsString() && !Buffer::HasInstance(args[0]))) { @@ -1675,7 +1675,7 @@ void Connection::SetSession(const FunctionCallbackInfo& args) { void Connection::LoadSession(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (args.Length() >= 1 && Buffer::HasInstance(args[0])) { ssize_t slen = Buffer::Length(args[0].As()); @@ -1697,7 +1697,7 @@ void Connection::LoadSession(const FunctionCallbackInfo& args) { void Connection::IsSessionReused(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); bool yes = conn->ssl_ && SSL_session_reused(conn->ssl_); args.GetReturnValue().Set(yes); } @@ -1706,7 +1706,7 @@ void Connection::IsSessionReused(const FunctionCallbackInfo& args) { void Connection::Start(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); int rv = 0; if (!SSL_is_init_finished(conn->ssl_)) { @@ -1731,7 +1731,7 @@ void Connection::Start(const FunctionCallbackInfo& args) { void Connection::Shutdown(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (conn->ssl_ == NULL) { return args.GetReturnValue().Set(false); @@ -1746,7 +1746,7 @@ void Connection::Shutdown(const FunctionCallbackInfo& args) { void Connection::ReceivedShutdown(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); bool yes = conn->ssl_ && SSL_get_shutdown(conn->ssl_) == SSL_RECEIVED_SHUTDOWN; args.GetReturnValue().Set(yes); @@ -1755,7 +1755,7 @@ void Connection::ReceivedShutdown(const FunctionCallbackInfo& args) { void Connection::IsInitFinished(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); bool yes = conn->ssl_ && SSL_is_init_finished(conn->ssl_); args.GetReturnValue().Set(yes); } @@ -1764,7 +1764,7 @@ void Connection::IsInitFinished(const FunctionCallbackInfo& args) { void Connection::VerifyError(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (conn->ssl_ == NULL) { return args.GetReturnValue().SetNull(); @@ -1920,7 +1920,7 @@ void Connection::VerifyError(const FunctionCallbackInfo& args) { void Connection::GetCurrentCipher(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (conn->ssl_ == NULL) return; OPENSSL_CONST SSL_CIPHER *c = SSL_get_current_cipher(conn->ssl_); @@ -1938,7 +1938,7 @@ void Connection::GetCurrentCipher(const FunctionCallbackInfo& args) { void Connection::Close(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (conn->ssl_ != NULL) { SSL_free(conn->ssl_); @@ -1951,7 +1951,7 @@ void Connection::Close(const FunctionCallbackInfo& args) { void Connection::GetNegotiatedProto(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (conn->is_server_) { const unsigned char* npn_proto; @@ -1974,7 +1974,7 @@ void Connection::GetNegotiatedProto(const FunctionCallbackInfo& args) { void Connection::SetNPNProtocols(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (args.Length() < 1 || !Buffer::HasInstance(args[0])) { return ThrowError("Must give a Buffer as first argument"); @@ -1989,7 +1989,7 @@ void Connection::SetNPNProtocols(const FunctionCallbackInfo& args) { void Connection::GetServername(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (conn->is_server_ && !conn->servername_.IsEmpty()) { args.GetReturnValue().Set(conn->servername_); @@ -2002,7 +2002,7 @@ void Connection::GetServername(const FunctionCallbackInfo& args) { void Connection::SetSNICallback(const FunctionCallbackInfo& args) { HandleScope scope(node_isolate); - Connection* conn = Connection::Unwrap(args); + Connection* conn = Connection::Unwrap(args.This()); if (args.Length() < 1 || !args[0]->IsFunction()) { return ThrowError("Must give a Function as first argument"); diff --git a/src/node_crypto.h b/src/node_crypto.h index 3ccd392..d48bea2 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -201,8 +201,8 @@ class Connection : ObjectWrap { void ClearError(); void SetShutdownFlags(); - static Connection* Unwrap(const v8::FunctionCallbackInfo& args) { - Connection* conn = ObjectWrap::Unwrap(args.This()); + static Connection* Unwrap(v8::Local object) { + Connection* conn = ObjectWrap::Unwrap(object); conn->ClearError(); return conn; } -- 2.7.4