mirror of
https://gitee.com/openharmony/third_party_nghttp2
synced 2024-11-27 01:50:28 +00:00
Ignore all incoming bytes when first SETTINGS is not received
This commit is contained in:
parent
58d3b5b4a0
commit
9c30211da9
@ -4684,12 +4684,8 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||
|
||||
if (iframe->sbuf.pos[3] != NGHTTP2_SETTINGS ||
|
||||
(iframe->sbuf.pos[4] & NGHTTP2_FLAG_ACK)) {
|
||||
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;
|
||||
iframe->state = NGHTTP2_IB_IGN_ALL;
|
||||
|
||||
rv = nghttp2_session_terminate_session_with_reason(
|
||||
session, NGHTTP2_PROTOCOL_ERROR, "SETTINGS expected");
|
||||
@ -4698,7 +4694,7 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||
return rv;
|
||||
}
|
||||
|
||||
break;
|
||||
return inlen;
|
||||
}
|
||||
|
||||
iframe->state = NGHTTP2_IB_READ_HEAD;
|
||||
@ -5649,6 +5645,8 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
|
||||
session_inbound_frame_reset(session);
|
||||
|
||||
break;
|
||||
case NGHTTP2_IB_IGN_ALL:
|
||||
return inlen;
|
||||
}
|
||||
|
||||
if (!busy && in == last) {
|
||||
|
@ -81,7 +81,8 @@ typedef enum {
|
||||
NGHTTP2_IB_IGN_CONTINUATION,
|
||||
NGHTTP2_IB_READ_PAD_DATA,
|
||||
NGHTTP2_IB_READ_DATA,
|
||||
NGHTTP2_IB_IGN_DATA
|
||||
NGHTTP2_IB_IGN_DATA,
|
||||
NGHTTP2_IB_IGN_ALL,
|
||||
} nghttp2_inbound_state;
|
||||
|
||||
#define NGHTTP2_INBOUND_NUM_IV 7
|
||||
|
@ -6581,15 +6581,15 @@ 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 */
|
||||
/* Receiving PING is error because we want SETTINGS. */
|
||||
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);
|
||||
CU_ASSERT(NGHTTP2_IB_IGN_ALL == session->iframe.state);
|
||||
CU_ASSERT(0 == session->iframe.payloadleft);
|
||||
|
||||
nghttp2_frame_ping_free(&ping_frame.ping);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user