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 <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
  • Loading branch information
jasnell authored and rvagg committed Aug 15, 2018
1 parent 4dfafac commit 83373e2
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 83373e2

Please sign in to comment.