Skip to content

Commit c9f6776

Browse files
committed
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: #7494 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 46f40cf commit c9f6776

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/node_crypto_clienthello.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void ClientHelloParser::ParseHeader(const uint8_t* data, size_t avail) {
103103
}
104104

105105

106-
void ClientHelloParser::ParseExtension(ClientHelloParser::ExtensionType type,
106+
void ClientHelloParser::ParseExtension(const uint16_t type,
107107
const uint8_t* data,
108108
size_t len) {
109109
// 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) {
210210
if (ext_off + ext_len > avail)
211211
return false;
212212

213-
ParseExtension(static_cast<ExtensionType>(ext_type),
213+
ParseExtension(ext_type,
214214
data + ext_off,
215215
ext_len);
216216

src/node_crypto_clienthello.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class ClientHelloParser {
9191

9292
bool ParseRecordHeader(const uint8_t* data, size_t avail);
9393
void ParseHeader(const uint8_t* data, size_t avail);
94-
void ParseExtension(ExtensionType type,
94+
void ParseExtension(const uint16_t type,
9595
const uint8_t* data,
9696
size_t len);
9797
bool ParseTLSClientHello(const uint8_t* data, size_t avail);

0 commit comments

Comments
 (0)