From 1e5069d58deb668f890c319723c8d9200c8ccedc Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 13 Dec 2017 14:51:33 +0100 Subject: [PATCH 1/2] src: fix compile warnings introduced in 73ad3f9bea Fix warnings introduced in commit 73ad3f9bea ("inspector: Fix crash for WS connection"): * add missing `override` keywords * remove unused fields and functions --- src/inspector_socket.cc | 4 ++-- src/inspector_socket_server.cc | 11 +---------- test/cctest/test_inspector_socket.cc | 1 - 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/inspector_socket.cc b/src/inspector_socket.cc index 23b77f6aa5609f..386b4c3af07a2d 100644 --- a/src/inspector_socket.cc +++ b/src/inspector_socket.cc @@ -328,7 +328,7 @@ class WsHandler : public ProtocolHandler { } while (processed > 0 && !data->empty()); } - void Write(const std::vector data) { + void Write(const std::vector data) override { std::vector output = encode_frame_hybi17(data); WriteRaw(output, WriteRequest::Cleanup); } @@ -446,7 +446,7 @@ class HttpHandler : public ProtocolHandler { } } - void CancelHandshake() { + void CancelHandshake() override { const char HANDSHAKE_FAILED_RESPONSE[] = "HTTP/1.0 400 Bad Request\r\n" "Content-Type: text/html; charset=UTF-8\r\n\r\n" diff --git a/src/inspector_socket_server.cc b/src/inspector_socket_server.cc index bf114251cb134b..03e5c60e65641e 100644 --- a/src/inspector_socket_server.cc +++ b/src/inspector_socket_server.cc @@ -84,11 +84,6 @@ const char* MatchPathSegment(const char* path, const char* expected) { return nullptr; } -void OnBufferAlloc(uv_handle_t* handle, size_t len, uv_buf_t* buf) { - buf->base = new char[len]; - buf->len = len; -} - void PrintDebuggerReadyMessage(const std::string& host, int port, const std::vector& ids, @@ -235,7 +230,6 @@ class SocketSession { private: const int id_; InspectorSocket::Pointer ws_socket_; - InspectorSocketServer* server_; const int server_port_; std::string ws_key_; }; @@ -531,10 +525,7 @@ void InspectorSocketServer::Send(int session_id, const std::string& message) { // InspectorSession tracking SocketSession::SocketSession(InspectorSocketServer* server, int id, int server_port) - : id_(id), - server_(server), - server_port_(server_port) { } - + : id_(id), server_port_(server_port) {} void SocketSession::Send(const std::string& message) { ws_socket_->Write(message.data(), message.length()); diff --git a/test/cctest/test_inspector_socket.cc b/test/cctest/test_inspector_socket.cc index 943109b8a594d2..debbc957379375 100644 --- a/test/cctest/test_inspector_socket.cc +++ b/test/cctest/test_inspector_socket.cc @@ -186,7 +186,6 @@ class TestInspectorDelegate : public InspectorSocket::Delegate { void process(inspector_handshake_event event, const std::string& path); - bool disposed_ = false; delegate_fn handshake_delegate_; InspectorSocket::Pointer socket_; std::string ws_key_; From 23fd5a96c3622ead540011bfd52bd10497a6465c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 13 Dec 2017 14:51:33 +0100 Subject: [PATCH 2/2] src: fix -Wundefined-inline warnings Fix compiler warnings introduced in commit 47edfd9c3c ("crypto: move node_crypto_clienthello-inl.h to cc") by moving constructors around. They were defined inline but depended on definitions from `node_crypto_clienthello-inl.h`. --- src/node_crypto.cc | 18 ++++++++++++++++++ src/node_crypto.h | 14 +------------- src/node_crypto_clienthello-inl.h | 15 +++++++++++++++ src/node_crypto_clienthello.h | 14 +------------- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 614c1067c6cc1b..480be4dd15e8fb 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -2849,6 +2849,24 @@ int SSLWrap::SetCACerts(SecureContext* sc) { } +Connection::Connection(Environment* env, + v8::Local wrap, + SecureContext* sc, + SSLWrap::Kind kind) + : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_SSLCONNECTION), + SSLWrap(env, sc, kind), + bio_read_(nullptr), + bio_write_(nullptr), + hello_offset_(0) { + MakeWeak(this); + Wrap(wrap, this); + hello_parser_.Start(SSLWrap::OnClientHello, + OnClientHelloParseEnd, + this); + enable_session_callbacks(); +} + + void Connection::OnClientHelloParseEnd(void* arg) { Connection* conn = static_cast(arg); diff --git a/src/node_crypto.h b/src/node_crypto.h index 636cbb99d4dde6..463be5f0727000 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -432,19 +432,7 @@ class Connection : public AsyncWrap, public SSLWrap { Connection(Environment* env, v8::Local wrap, SecureContext* sc, - SSLWrap::Kind kind) - : AsyncWrap(env, wrap, AsyncWrap::PROVIDER_SSLCONNECTION), - SSLWrap(env, sc, kind), - bio_read_(nullptr), - bio_write_(nullptr), - hello_offset_(0) { - MakeWeak(this); - Wrap(wrap, this); - hello_parser_.Start(SSLWrap::OnClientHello, - OnClientHelloParseEnd, - this); - enable_session_callbacks(); - } + SSLWrap::Kind kind); private: static void SSLInfoCallback(const SSL *ssl, int where, int ret); diff --git a/src/node_crypto_clienthello-inl.h b/src/node_crypto_clienthello-inl.h index 019d7188de6cf3..5aff1816b2f73e 100644 --- a/src/node_crypto_clienthello-inl.h +++ b/src/node_crypto_clienthello-inl.h @@ -30,6 +30,21 @@ namespace node { namespace crypto { +inline ClientHelloParser::ClientHelloParser() + : state_(kEnded), + onhello_cb_(nullptr), + onend_cb_(nullptr), + cb_arg_(nullptr), + session_size_(0), + session_id_(nullptr), + servername_size_(0), + servername_(nullptr), + ocsp_request_(0), + tls_ticket_size_(0), + tls_ticket_(nullptr) { + Reset(); +} + inline void ClientHelloParser::Reset() { frame_len_ = 0; body_offset_ = 0; diff --git a/src/node_crypto_clienthello.h b/src/node_crypto_clienthello.h index 70f082b2c2a038..32c470677d04c0 100644 --- a/src/node_crypto_clienthello.h +++ b/src/node_crypto_clienthello.h @@ -33,19 +33,7 @@ namespace crypto { class ClientHelloParser { public: - ClientHelloParser() : state_(kEnded), - onhello_cb_(nullptr), - onend_cb_(nullptr), - cb_arg_(nullptr), - session_size_(0), - session_id_(nullptr), - servername_size_(0), - servername_(nullptr), - ocsp_request_(0), - tls_ticket_size_(0), - tls_ticket_(nullptr) { - Reset(); - } + inline ClientHelloParser(); class ClientHello { public: