Skip to content

Commit 4e37ac4

Browse files
author
sankalpsthakur
committed
tls: throw on invalid ALPNProtocols instead of aborting
Fixes nodejs#65069 tls.connect() with malformed ALPNProtocols (empty string, invalid wire format buffers) hits CHECK_EQ(0, SSL_set_alpn_protos(...)) and aborts the process with SIGABRT. Replace the hard abort with THROW_ERR_INVALID_ARG_VALUE so invalid input throws a recoverable JavaScript exception. Assisted-by: Codex Signed-off-by: sankalpsthakur <[email protected]>
1 parent ee64033 commit 4e37ac4

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎src/crypto/crypto_tls.cc‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,7 +1702,10 @@ void TLSWrap::SetALPNProtocols(const FunctionCallbackInfo<Value>& args) {
17021702
ArrayBufferViewContents<uint8_t> protos(args[0].As<ArrayBufferView>());
17031703
SSL* ssl = w->ssl_.get();
17041704
if (w->is_client()) {
1705-
CHECK_EQ(0, SSL_set_alpn_protos(ssl, protos.data(), protos.length()));
1705+
if (SSL_set_alpn_protos(ssl, protos.data(), protos.length()) != 0) {
1706+
return THROW_ERR_INVALID_ARG_VALUE(
1707+
env, "Invalid ALPNProtocols value");
1708+
}
17061709
} else {
17071710
w->alpn_protos_ = std::vector<unsigned char>(
17081711
protos.data(), protos.data() + protos.length());

0 commit comments

Comments
 (0)