Skip to content

Commit 5c3edd3

Browse files
jasnellBethGriggs
authored andcommitted
http2: avoid race condition in OnHeaderCallback
Fixes: #21416 Backport-PR-URL: #22850 PR-URL: #22256 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: George Adams <[email protected]>
1 parent 3980ca1 commit 5c3edd3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/node_http2.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,12 @@ inline int Http2Session::OnHeaderCallback(nghttp2_session* handle,
933933
Http2Session* session = static_cast<Http2Session*>(user_data);
934934
int32_t id = GetFrameID(frame);
935935
Http2Stream* stream = session->FindStream(id);
936-
CHECK_NE(stream, nullptr);
936+
// If stream is null at this point, either something odd has happened
937+
// or the stream was closed locally while header processing was occurring.
938+
// either way, do not proceed and close the stream.
939+
if (stream == nullptr)
940+
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
941+
937942
// If the stream has already been destroyed, ignore.
938943
if (stream->IsDestroyed())
939944
return 0;

0 commit comments

Comments
 (0)