Filter supported flags in received frame

This commit is contained in:
Tatsuhiro Tsujikawa 2014-03-05 23:25:42 +09:00
parent 547d6d1fb5
commit b60679808b
1 changed files with 17 additions and 0 deletions

View File

@ -3606,6 +3606,10 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
switch(iframe->frame.hd.type) { switch(iframe->frame.hd.type) {
case NGHTTP2_DATA: { case NGHTTP2_DATA: {
DEBUGF(fprintf(stderr, "DATA\n")); DEBUGF(fprintf(stderr, "DATA\n"));
iframe->frame.hd.flags &= (NGHTTP2_FLAG_END_STREAM |
NGHTTP2_FLAG_END_SEGMENT |
NGHTTP2_FLAG_PAD_LOW |
NGHTTP2_FLAG_PAD_HIGH);
/* Check stream is open. If it is not open or closing, /* Check stream is open. If it is not open or closing,
ignore payload. */ ignore payload. */
busy = 1; busy = 1;
@ -3637,6 +3641,12 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
break; break;
} }
case NGHTTP2_HEADERS: case NGHTTP2_HEADERS:
iframe->frame.hd.flags &= (NGHTTP2_FLAG_END_STREAM |
NGHTTP2_FLAG_END_SEGMENT |
NGHTTP2_FLAG_END_HEADERS |
NGHTTP2_FLAG_PRIORITY |
NGHTTP2_FLAG_PAD_LOW |
NGHTTP2_FLAG_PAD_HIGH);
DEBUGF(fprintf(stderr, "HEADERS\n")); DEBUGF(fprintf(stderr, "HEADERS\n"));
rv = inbound_frame_handle_pad(iframe, &iframe->frame.hd); rv = inbound_frame_handle_pad(iframe, &iframe->frame.hd);
if(rv < 0) { if(rv < 0) {
@ -3690,6 +3700,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
break; break;
} }
#endif /* DEBUGBUILD */ #endif /* DEBUGBUILD */
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
if(iframe->payloadleft != 4) { if(iframe->payloadleft != 4) {
busy = 1; busy = 1;
iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR; iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR;
@ -3700,6 +3711,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
break; break;
case NGHTTP2_SETTINGS: case NGHTTP2_SETTINGS:
DEBUGF(fprintf(stderr, "SETTINGS\n")); DEBUGF(fprintf(stderr, "SETTINGS\n"));
iframe->frame.hd.flags &= NGHTTP2_FLAG_ACK;
if((iframe->frame.hd.length % NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH) || if((iframe->frame.hd.length % NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH) ||
((iframe->frame.hd.flags & NGHTTP2_FLAG_ACK) && ((iframe->frame.hd.flags & NGHTTP2_FLAG_ACK) &&
iframe->payloadleft > 0)) { iframe->payloadleft > 0)) {
@ -3718,6 +3730,9 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
break; break;
case NGHTTP2_PUSH_PROMISE: case NGHTTP2_PUSH_PROMISE:
DEBUGF(fprintf(stderr, "PUSH_PROMISE\n")); DEBUGF(fprintf(stderr, "PUSH_PROMISE\n"));
iframe->frame.hd.flags &= (NGHTTP2_FLAG_END_HEADERS |
NGHTTP2_FLAG_PAD_LOW |
NGHTTP2_FLAG_PAD_HIGH);
rv = inbound_frame_handle_pad(iframe, &iframe->frame.hd); rv = inbound_frame_handle_pad(iframe, &iframe->frame.hd);
if(rv < 0) { if(rv < 0) {
busy = 1; busy = 1;
@ -3743,6 +3758,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
break; break;
case NGHTTP2_PING: case NGHTTP2_PING:
DEBUGF(fprintf(stderr, "PING\n")); DEBUGF(fprintf(stderr, "PING\n"));
iframe->frame.hd.flags &= NGHTTP2_FLAG_ACK;
if(iframe->payloadleft != 8) { if(iframe->payloadleft != 8) {
busy = 1; busy = 1;
iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR; iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR;
@ -3753,6 +3769,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session,
break; break;
case NGHTTP2_GOAWAY: case NGHTTP2_GOAWAY:
DEBUGF(fprintf(stderr, "GOAWAY\n")); DEBUGF(fprintf(stderr, "GOAWAY\n"));
iframe->frame.hd.flags = NGHTTP2_FLAG_NONE;
if(iframe->payloadleft < 8) { if(iframe->payloadleft < 8) {
busy = 1; busy = 1;
iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR; iframe->state = NGHTTP2_IB_FRAME_SIZE_ERROR;