diff --git a/lib/nghttp2_frame.c b/lib/nghttp2_frame.c index b9bf4288..fb2f961a 100644 --- a/lib/nghttp2_frame.c +++ b/lib/nghttp2_frame.c @@ -1045,8 +1045,6 @@ int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv) break; case NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE: break; - default: - return 0; } } return 1; diff --git a/tests/nghttp2_frame_test.c b/tests/nghttp2_frame_test.c index 7c1ce142..beb7baa7 100644 --- a/tests/nghttp2_frame_test.c +++ b/tests/nghttp2_frame_test.c @@ -700,10 +700,10 @@ void test_nghttp2_iv_check(void) iv[1].value = 3; CU_ASSERT(!nghttp2_iv_check(iv, 2)); - /* Undefined SETTINGS ID */ + /* Undefined SETTINGS ID is allowed */ iv[1].settings_id = 1000000009; iv[1].value = 0; - CU_ASSERT(!nghttp2_iv_check(iv, 2)); + CU_ASSERT(nghttp2_iv_check(iv, 2)); /* Too large SETTINGS_HEADER_TABLE_SIZE */ iv[1].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index 88358157..bf89121b 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -3485,8 +3485,9 @@ void test_nghttp2_submit_settings(void) my_user_data ud; nghttp2_outbound_item *item; nghttp2_frame *frame; - nghttp2_settings_entry iv[6]; + nghttp2_settings_entry iv[7]; nghttp2_frame ack_frame; + const int32_t UNKNOWN_ID = 1000000007; iv[0].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS; iv[0].value = 5; @@ -3500,8 +3501,11 @@ void test_nghttp2_submit_settings(void) iv[3].settings_id = NGHTTP2_SETTINGS_HEADER_TABLE_SIZE; iv[3].value = 0; - iv[4].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; - iv[4].value = (uint32_t)NGHTTP2_MAX_WINDOW_SIZE + 1; + iv[4].settings_id = UNKNOWN_ID; + iv[4].value = 999; + + iv[5].settings_id = NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; + iv[5].value = (uint32_t)NGHTTP2_MAX_WINDOW_SIZE + 1; memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); callbacks.send_callback = null_send_callback; @@ -3509,7 +3513,7 @@ void test_nghttp2_submit_settings(void) nghttp2_session_server_new(&session, &callbacks, &ud); CU_ASSERT(NGHTTP2_ERR_INVALID_ARGUMENT == - nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 5)); + nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 6)); /* Make sure that local settings are not changed */ CU_ASSERT(NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS == @@ -3517,15 +3521,15 @@ void test_nghttp2_submit_settings(void) CU_ASSERT(NGHTTP2_INITIAL_WINDOW_SIZE == session->local_settings.initial_window_size); - /* Now sends without 5th one */ - CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 4)); + /* Now sends without 6th one */ + CU_ASSERT(0 == nghttp2_submit_settings(session, NGHTTP2_FLAG_NONE, iv, 5)); item = nghttp2_session_get_next_ob_item(session); CU_ASSERT(NGHTTP2_SETTINGS == OB_CTRL_TYPE(item)); frame = item->frame; - CU_ASSERT(4 == frame->settings.niv); + CU_ASSERT(5 == frame->settings.niv); CU_ASSERT(5 == frame->settings.iv[0].value); CU_ASSERT(NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS == frame->settings.iv[0].settings_id); @@ -3534,6 +3538,9 @@ void test_nghttp2_submit_settings(void) CU_ASSERT(NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE == frame->settings.iv[1].settings_id); + CU_ASSERT(UNKNOWN_ID == frame->settings.iv[4].settings_id); + CU_ASSERT(999 == frame->settings.iv[4].value); + ud.frame_send_cb_called = 0; CU_ASSERT(0 == nghttp2_session_send(session)); CU_ASSERT(1 == ud.frame_send_cb_called);