Skip to content

Commit

Permalink
crypto: fix undefined behavior in ParseExtension
Browse files Browse the repository at this point in the history
Many extensions are unknown to the `ClientHelloParser::ParseExtension`,
do not cast user-supplied `uint16_t` to `enum`.

PR-URL: #7494
Reviewed-By: Ben Noordhuis <[email protected]>
  • Loading branch information
indutny committed Jul 11, 2016
1 parent 46f40cf commit c9f6776
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/node_crypto_clienthello.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<ExtensionType>(ext_type),
ParseExtension(ext_type,
data + ext_off,
ext_len);

Expand Down
2 changes: 1 addition & 1 deletion src/node_crypto_clienthello.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c9f6776

Please sign in to comment.