Skip to content

Commit a01afe2

Browse files
sankalpsthakursankalpsthakur
authored andcommitted
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 a48e33f commit a01afe2

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
@@ -1699,7 +1699,10 @@ void TLSWrap::SetALPNProtocols(const FunctionCallbackInfo<Value>& args) {
16991699
ArrayBufferViewContents<uint8_t> protos(args[0].As<ArrayBufferView>());
17001700
SSL* ssl = w->ssl_.get();
17011701
if (w->is_client()) {
1702-
CHECK_EQ(0, SSL_set_alpn_protos(ssl, protos.data(), protos.length()));
1702+
if (SSL_set_alpn_protos(ssl, protos.data(), protos.length()) != 0) {
1703+
return THROW_ERR_INVALID_ARG_VALUE(
1704+
env, "Invalid ALPNProtocols value");
1705+
}
17031706
} else {
17041707
w->alpn_protos_ = std::vector<unsigned char>(
17051708
protos.data(), protos.data() + protos.length());

0 commit comments

Comments
 (0)