Commit 01586f47 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Wrap small inbound buffer by nghttp_buf

parent 3c631b56
......@@ -52,6 +52,7 @@ typedef struct {
#define nghttp2_buf_len(BUF) ((BUF)->last - (BUF)->pos)
#define nghttp2_buf_avail(BUF) ((BUF)->end - (BUF)->last)
#define nghttp2_buf_mark_avail(BUF) ((BUF)->mark - (BUF)->last)
#define nghttp2_buf_cap(BUF) ((BUF)->end - (BUF)->begin)
#define nghttp2_buf_pos_offset(BUF) ((BUF)->pos - (BUF)->begin)
......
This diff is collapsed.
......@@ -88,18 +88,20 @@ typedef struct {
about the defined settings ID. If unknown ID is received, it is
subject to connection error */
nghttp2_settings_entry iv[5];
/* buffer pointers to small buffer, raw_sbuf */
nghttp2_buf sbuf;
/* buffer pointers to large buffer, raw_lbuf */
nghttp2_buf lbuf;
/* Large buffer, malloced on demand */
uint8_t *raw_lbuf;
/* The number of entry filled in |iv| */
size_t niv;
/* How many bytes we still need to receive in the |buf| */
size_t left;
/* How many bytes we still need to receive for current frame */
size_t payloadleft;
/* padding length for the current frame */
size_t padlen;
nghttp2_inbound_state state;
uint8_t buf[8];
/* How many bytes have been written to |buf| */
uint8_t buflen;
uint8_t raw_sbuf[8];
} nghttp2_inbound_frame;
typedef enum {
......
......@@ -1141,8 +1141,7 @@ void test_nghttp2_session_on_request_headers_received(void)
callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback;
nghttp2_session_server_new(&session, &callbacks, &user_data);
memset(session->iframe.buf, 0, 4);
session->iframe.buflen = 4;
nghttp2_frame_headers_init(&frame.headers,
NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY,
stream_id, 1 << 20, NULL, 0);
......@@ -1190,8 +1189,7 @@ void test_nghttp2_session_on_request_headers_received(void)
/* Check malformed headers. The library accept it. */
nghttp2_session_server_new(&session, &callbacks, &user_data);
memset(session->iframe.buf, 0, 4);
session->iframe.buflen = 4;
nvlen = nghttp2_nv_array_copy(&nva, malformed_nva, ARRLEN(malformed_nva));
nghttp2_frame_headers_init(&frame.headers,
NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_PRIORITY,
......@@ -1584,8 +1582,7 @@ void test_nghttp2_session_on_push_promise_received(void)
callbacks.on_invalid_frame_recv_callback = on_invalid_frame_recv_callback;
nghttp2_session_client_new(&session, &callbacks, &user_data);
memset(session->iframe.buf, 0, 4);
session->iframe.buflen = 4;
stream = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
NGHTTP2_PRI_DEFAULT,
NGHTTP2_STREAM_OPENING, NULL);
......@@ -1660,8 +1657,6 @@ void test_nghttp2_session_on_push_promise_received(void)
nghttp2_session_del(session);
nghttp2_session_client_new(&session, &callbacks, &user_data);
memset(session->iframe.buf, 0, 4);
session->iframe.buflen = 4;
stream = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
NGHTTP2_PRI_DEFAULT,
......@@ -1698,8 +1693,7 @@ void test_nghttp2_session_on_push_promise_received(void)
nghttp2_session_del(session);
nghttp2_session_client_new(&session, &callbacks, &user_data);
memset(session->iframe.buf, 0, 4);
session->iframe.buflen = 4;
stream = nghttp2_session_open_stream(session, 2, NGHTTP2_STREAM_FLAG_NONE,
NGHTTP2_PRI_DEFAULT,
NGHTTP2_STREAM_RESERVED, NULL);
......@@ -1721,8 +1715,7 @@ void test_nghttp2_session_on_push_promise_received(void)
/* Disable PUSH */
nghttp2_session_client_new(&session, &callbacks, &user_data);
memset(session->iframe.buf, 0, 4);
session->iframe.buflen = 4;
stream = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
NGHTTP2_PRI_DEFAULT,
NGHTTP2_STREAM_OPENING, NULL);
......@@ -1746,8 +1739,7 @@ void test_nghttp2_session_on_push_promise_received(void)
/* Check malformed headers. We accept malformed headers */
nghttp2_session_client_new(&session, &callbacks, &user_data);
memset(session->iframe.buf, 0, 4);
session->iframe.buflen = 4;
stream = nghttp2_session_open_stream(session, 1, NGHTTP2_STREAM_FLAG_NONE,
NGHTTP2_PRI_DEFAULT,
NGHTTP2_STREAM_OPENING, NULL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment