Skip to content

Commit 83373e2

Browse files
jasnellrvagg
authored andcommitted
http2: avoid race condition in OnHeaderCallback
Fixes: #21416 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 4dfafac commit 83373e2

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
@@ -881,7 +881,12 @@ int Http2Session::OnHeaderCallback(nghttp2_session* handle,
881881
Http2Session* session = static_cast<Http2Session*>(user_data);
882882
int32_t id = GetFrameID(frame);
883883
Http2Stream* stream = session->FindStream(id);
884-
CHECK_NOT_NULL(stream);
884+
// If stream is null at this point, either something odd has happened
885+
// or the stream was closed locally while header processing was occurring.
886+
// either way, do not proceed and close the stream.
887+
if (stream == nullptr)
888+
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
889+
885890
// If the stream has already been destroyed, ignore.
886891
if (!stream->IsDestroyed() && !stream->AddHeader(name, value, flags)) {
887892
// This will only happen if the connected peer sends us more

0 commit comments

Comments
 (0)