diff --git a/lib/nghttp2_submit.c b/lib/nghttp2_submit.c index 828d8f27..cc543b54 100644 --- a/lib/nghttp2_submit.c +++ b/lib/nghttp2_submit.c @@ -129,12 +129,15 @@ static int nghttp2_submit_headers_shared_nva NGHTTP2_PRIORITY_TYPE_NONE }; - rv = nghttp2_nv_array_copy(&nva_copy, nva, nvlen); - if(rv < 0) { - return rv; - } - if(pri_spec) { + switch(pri_spec->pri_type) { + case NGHTTP2_PRIORITY_TYPE_GROUP: + case NGHTTP2_PRIORITY_TYPE_DEP: + break; + default: + return NGHTTP2_ERR_INVALID_ARGUMENT; + } + copy_pri_spec = *pri_spec; if(copy_pri_spec.pri_type == NGHTTP2_PRIORITY_TYPE_GROUP) { @@ -142,6 +145,11 @@ static int nghttp2_submit_headers_shared_nva } } + rv = nghttp2_nv_array_copy(&nva_copy, nva, nvlen); + if(rv < 0) { + return rv; + } + return nghttp2_submit_headers_shared(session, flags, stream_id, ©_pri_spec, nva_copy, rv, data_prd, stream_user_data); @@ -263,6 +271,10 @@ int nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags, nghttp2_headers_aux_data *aux_data = NULL; int rv; + if(!session->server) { + return NGHTTP2_ERR_PROTO; + } + frame = malloc(sizeof(nghttp2_frame)); if(frame == NULL) { return NGHTTP2_ERR_NOMEM; @@ -347,7 +359,7 @@ int nghttp2_submit_altsvc(nghttp2_session *session, uint8_t flags, uint8_t *copy_protocol_id, *copy_host, *copy_origin; if(!session->server) { - return NGHTTP2_ERR_INVALID_STATE; + return NGHTTP2_ERR_PROTO; } varlen = protocol_id_len + host_len + origin_len; diff --git a/tests/nghttp2_session_test.c b/tests/nghttp2_session_test.c index caa068c6..5f5f451b 100644 --- a/tests/nghttp2_session_test.c +++ b/tests/nghttp2_session_test.c @@ -3484,7 +3484,7 @@ void test_nghttp2_submit_altsvc(void) nghttp2_session_client_new(&session, &callbacks, NULL); - CU_ASSERT(NGHTTP2_ERR_INVALID_STATE == + CU_ASSERT(NGHTTP2_ERR_PROTO == nghttp2_submit_altsvc(session, NGHTTP2_FLAG_NONE, 0, 0, 3000, (const uint8_t*)protocol_id, @@ -3548,7 +3548,7 @@ void test_nghttp2_submit_invalid_nv(void) memset(&callbacks, 0, sizeof(nghttp2_session_callbacks)); - CU_ASSERT(0 == nghttp2_session_client_new(&session, &callbacks, NULL)); + CU_ASSERT(0 == nghttp2_session_server_new(&session, &callbacks, NULL)); /* nghttp2_submit_request */ CU_ASSERT(0 ==