Skip to content

Commit f5985c7

Browse files
addaleaxMylesBorins
authored andcommitted
tls,http2: handle writes after SSL destroy more gracefully
This might otherwise result in a hard crash when trying to write to a socket after a sudden disconnect. Note that the test here uses an aborted `h2load` run to create the failing requests; That’s far from ideal, but it provides a reasonably reliably reproduction at this point. Backport-PR-URL: #22924 PR-URL: #18987 Fixes: #18973 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 8209ccb commit f5985c7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/tls_wrap.cc

+6-7
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,12 @@ int TLSWrap::DoWrite(WriteWrap* w,
601601
size_t count,
602602
uv_stream_t* send_handle) {
603603
CHECK_EQ(send_handle, nullptr);
604-
CHECK_NE(ssl_, nullptr);
604+
605+
if (ssl_ == nullptr) {
606+
ClearError();
607+
error_ = "Write after DestroySSL";
608+
return UV_EPROTO;
609+
}
605610

606611
bool empty = true;
607612

@@ -642,12 +647,6 @@ int TLSWrap::DoWrite(WriteWrap* w,
642647
return 0;
643648
}
644649

645-
if (ssl_ == nullptr) {
646-
ClearError();
647-
error_ = "Write after DestroySSL";
648-
return UV_EPROTO;
649-
}
650-
651650
crypto::MarkPopErrorOnReturn mark_pop_error_on_return;
652651

653652
int written = 0;

0 commit comments

Comments
 (0)