From c9f6776d2b853bc89a12527ab799a514898c0eec Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Thu, 30 Jun 2016 03:42:54 -0400 Subject: [PATCH] crypto: fix undefined behavior in ParseExtension Many extensions are unknown to the `ClientHelloParser::ParseExtension`, do not cast user-supplied `uint16_t` to `enum`. PR-URL: https://github.com/nodejs/node/pull/7494 Reviewed-By: Ben Noordhuis --- src/node_crypto_clienthello.cc | 4 ++-- src/node_crypto_clienthello.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node_crypto_clienthello.cc b/src/node_crypto_clienthello.cc index 8fbc3161f89969..8c862c1b6a5198 100644 --- a/src/node_crypto_clienthello.cc +++ b/src/node_crypto_clienthello.cc @@ -103,7 +103,7 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) { } -void ClientHelloParser::ParseExtension(ClientHelloParser::ExtensionType type, +void ClientHelloParser::ParseExtension(const uint16_t type, const uint8_t* data, size_t len) { // NOTE: In case of anything we're just returning back, ignoring the problem. @@ -210,7 +210,7 @@ bool ClientHelloParser::ParseTLSClientHello(const uint8_t* data, size_t avail) { if (ext_off + ext_len > avail) return false; - ParseExtension(static_cast(ext_type), + ParseExtension(ext_type, data + ext_off, ext_len); diff --git a/src/node_crypto_clienthello.h b/src/node_crypto_clienthello.h index b0b63fb2e38138..3550807c20d05f 100644 --- a/src/node_crypto_clienthello.h +++ b/src/node_crypto_clienthello.h @@ -91,7 +91,7 @@ class ClientHelloParser { bool ParseRecordHeader(const uint8_t* data, size_t avail); void ParseHeader(const uint8_t* data, size_t avail); - void ParseExtension(ExtensionType type, + void ParseExtension(const uint16_t type, const uint8_t* data, size_t len); bool ParseTLSClientHello(const uint8_t* data, size_t avail);