From 59a0962ed4d3a7dd8965d2d546ba94cded1cf9cf Mon Sep 17 00:00:00 2001 From: Diana Holland Date: Fri, 12 Oct 2018 11:36:17 -0700 Subject: [PATCH 1/2] crypto: move field initialization to class --- src/node_crypto_clienthello-inl.h | 9 +-------- src/node_crypto_clienthello.h | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/node_crypto_clienthello-inl.h b/src/node_crypto_clienthello-inl.h index c5c595c7606cf9..9de8f2e5fcf731 100644 --- a/src/node_crypto_clienthello-inl.h +++ b/src/node_crypto_clienthello-inl.h @@ -34,14 +34,7 @@ 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) { + cb_arg_(nullptr) { Reset(); } diff --git a/src/node_crypto_clienthello.h b/src/node_crypto_clienthello.h index fd8756254ffc24..b2d9d2a6b70922 100644 --- a/src/node_crypto_clienthello.h +++ b/src/node_crypto_clienthello.h @@ -44,12 +44,12 @@ class ClientHelloParser { inline int ocsp_request() const { return ocsp_request_; } private: - uint8_t session_size_; - const uint8_t* session_id_; + uint8_t session_size_ = 0; + const uint8_t* session_id_ = nullptr; bool has_ticket_; - uint8_t servername_size_; - const uint8_t* servername_; - int ocsp_request_; + uint8_t servername_size_ = 0; + const uint8_t* servername_ = nullptr; + int ocsp_request_ = 0; friend class ClientHelloParser; }; @@ -108,16 +108,16 @@ class ClientHelloParser { OnHelloCb onhello_cb_; OnEndCb onend_cb_; void* cb_arg_; - size_t frame_len_; - size_t body_offset_; - size_t extension_offset_; + size_t frame_len_ = 0; + size_t body_offset_ = 0; + size_t extension_offset_ = 0; uint8_t session_size_; const uint8_t* session_id_; uint16_t servername_size_; const uint8_t* servername_; uint8_t ocsp_request_; - uint16_t tls_ticket_size_; - const uint8_t* tls_ticket_; + uint16_t tls_ticket_size_ = -1; + const uint8_t* tls_ticket_ = nullptr; }; } // namespace crypto From d2e44f58b1fc2b7a752697a51fd5823bcb2bc1a4 Mon Sep 17 00:00:00 2001 From: Diana Holland Date: Fri, 12 Oct 2018 14:35:11 -0700 Subject: [PATCH 2/2] crypto: complete ClientHelloParser initializers --- src/node_crypto_clienthello.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/node_crypto_clienthello.h b/src/node_crypto_clienthello.h index b2d9d2a6b70922..687e9589b6d932 100644 --- a/src/node_crypto_clienthello.h +++ b/src/node_crypto_clienthello.h @@ -44,12 +44,12 @@ class ClientHelloParser { inline int ocsp_request() const { return ocsp_request_; } private: - uint8_t session_size_ = 0; - const uint8_t* session_id_ = nullptr; + uint8_t session_size_; + const uint8_t* session_id_; bool has_ticket_; - uint8_t servername_size_ = 0; - const uint8_t* servername_ = nullptr; - int ocsp_request_ = 0; + uint8_t servername_size_; + const uint8_t* servername_; + int ocsp_request_; friend class ClientHelloParser; }; @@ -111,11 +111,11 @@ class ClientHelloParser { size_t frame_len_ = 0; size_t body_offset_ = 0; size_t extension_offset_ = 0; - uint8_t session_size_; - const uint8_t* session_id_; - uint16_t servername_size_; - const uint8_t* servername_; - uint8_t ocsp_request_; + uint8_t session_size_ = 0; + const uint8_t* session_id_ = nullptr; + uint16_t servername_size_ = 0; + const uint8_t* servername_ = nullptr; + uint8_t ocsp_request_ = 0; uint16_t tls_ticket_size_ = -1; const uint8_t* tls_ticket_ = nullptr; };