Skip to content

Commit

Permalink
http2: avoid race condition in OnHeaderCallback
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jasnell authored and rvagg committed Aug 15, 2018
1 parent fcf422e commit cee78bf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/node_http2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,12 @@ int Http2Session::OnHeaderCallback(nghttp2_session* handle,
Http2Session* session = static_cast<Http2Session*>(user_data);
int32_t id = GetFrameID(frame);
Http2Stream* stream = session->FindStream(id);
CHECK_NOT_NULL(stream);
// If stream is null at this point, either something odd has happened
// or the stream was closed locally while header processing was occurring.
// either way, do not proceed and close the stream.
if (stream == nullptr)
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;

// If the stream has already been destroyed, ignore.
if (!stream->IsDestroyed() && !stream->AddHeader(name, value, flags)) {
// This will only happen if the connected peer sends us more
Expand Down

0 comments on commit cee78bf

Please sign in to comment.