@@ -1031,8 +1031,7 @@ int Http2Session::OnFrameReceive(nghttp2_session* handle,
10311031 frame->hd .type );
10321032 switch (frame->hd .type ) {
10331033 case NGHTTP2_DATA:
1034- session->HandleDataFrame (frame);
1035- break ;
1034+ return session->HandleDataFrame (frame);
10361035 case NGHTTP2_PUSH_PROMISE:
10371036 // Intentional fall-through, handled just like headers frames
10381037 case NGHTTP2_HEADERS:
@@ -1408,18 +1407,18 @@ void Http2Session::HandlePriorityFrame(const nghttp2_frame* frame) {
14081407// Called by OnFrameReceived when a complete DATA frame has been received.
14091408// If we know that this was the last DATA frame (because the END_STREAM flag
14101409// is set), then we'll terminate the readable side of the StreamBase.
1411- inline void Http2Session::HandleDataFrame (const nghttp2_frame* frame) {
1410+ int Http2Session::HandleDataFrame (const nghttp2_frame* frame) {
14121411 int32_t id = GetFrameID (frame);
14131412 DEBUG_HTTP2SESSION2 (this , " handling data frame for stream %d" , id);
14141413 Http2Stream* stream = FindStream (id);
14151414
1416- // If the stream has already been destroyed, do nothing
1417- if (stream->IsDestroyed ())
1418- return ;
1419-
1420- if (frame->hd .flags & NGHTTP2_FLAG_END_STREAM) {
1415+ if (!stream->IsDestroyed () && frame->hd .flags & NGHTTP2_FLAG_END_STREAM) {
14211416 stream->EmitData (UV_EOF, Local<Object>(), Local<Object>());
1417+ } else if (frame->hd .length == 0 &&
1418+ !IsReverted (SECURITY_REVERT_CVE_2019_9518)) {
1419+ return 1 ; // Consider 0-length frame without END_STREAM an error.
14221420 }
1421+ return 0 ;
14231422}
14241423
14251424
0 commit comments