diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c index 6c06fdd3..d64a15a3 100644 --- a/lib/nghttp2_session.c +++ b/lib/nghttp2_session.c @@ -4413,6 +4413,9 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, } if(iframe->sbuf.pos[3] != NGHTTP2_SETTINGS) { + nghttp2_frame_unpack_frame_hd(&iframe->frame.hd, iframe->sbuf.pos); + iframe->payloadleft = iframe->frame.hd.length; + busy = 1; iframe->state = NGHTTP2_IB_IGN_PAYLOAD; diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 19598226..218fba42 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -6477,6 +6477,8 @@ void test_nghttp2_session_recv_client_preface(void) nghttp2_session_callbacks callbacks; nghttp2_option *option; ssize_t rv; + nghttp2_frame ping_frame; + uint8_t buf[16]; memset(&callbacks, 0, sizeof(callbacks)); @@ -6496,6 +6498,18 @@ void test_nghttp2_session_recv_client_preface(void) CU_ASSERT(rv == NGHTTP2_CLIENT_CONNECTION_PREFACE_LEN); CU_ASSERT(NGHTTP2_IB_READ_FIRST_SETTINGS == session->iframe.state); + /* Receiving PING is error */ + nghttp2_frame_ping_init(&ping_frame.ping, NGHTTP2_FLAG_NONE, NULL); + + nghttp2_frame_pack_frame_hd(buf, &ping_frame.ping.hd); + + rv = nghttp2_session_mem_recv(session, buf, NGHTTP2_FRAME_HDLEN); + CU_ASSERT(NGHTTP2_FRAME_HDLEN == rv); + CU_ASSERT(NGHTTP2_IB_IGN_PAYLOAD == session->iframe.state); + CU_ASSERT(8 == session->iframe.payloadleft); + + nghttp2_frame_ping_free(&ping_frame.ping); + nghttp2_session_del(session); /* Check bad case */