@@ -1031,8 +1031,7 @@ int Http2Session::OnFrameReceive(nghttp2_session* handle,
1031
1031
frame->hd .type );
1032
1032
switch (frame->hd .type ) {
1033
1033
case NGHTTP2_DATA:
1034
- session->HandleDataFrame (frame);
1035
- break ;
1034
+ return session->HandleDataFrame (frame);
1036
1035
case NGHTTP2_PUSH_PROMISE:
1037
1036
// Intentional fall-through, handled just like headers frames
1038
1037
case NGHTTP2_HEADERS:
@@ -1408,18 +1407,18 @@ void Http2Session::HandlePriorityFrame(const nghttp2_frame* frame) {
1408
1407
// Called by OnFrameReceived when a complete DATA frame has been received.
1409
1408
// If we know that this was the last DATA frame (because the END_STREAM flag
1410
1409
// 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) {
1412
1411
int32_t id = GetFrameID (frame);
1413
1412
DEBUG_HTTP2SESSION2 (this , " handling data frame for stream %d" , id);
1414
1413
Http2Stream* stream = FindStream (id);
1415
1414
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) {
1421
1416
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.
1422
1420
}
1421
+ return 0 ;
1423
1422
}
1424
1423
1425
1424
0 commit comments