Commit d75ba74b authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Return error if invalid stream_id is given to nghttp2_submit_push_promise

parent 9ff19255
...@@ -2802,7 +2802,8 @@ int nghttp2_submit_settings(nghttp2_session *session, uint8_t flags, ...@@ -2802,7 +2802,8 @@ int nghttp2_submit_settings(nghttp2_session *session, uint8_t flags,
* No stream ID is available because maximum stream ID was * No stream ID is available because maximum stream ID was
* reached. * reached.
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT` * :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
* The |stream_id| is 0. * The |stream_id| is 0; The |stream_id| does not designate stream
* that peer initiated.
* *
* .. warning:: * .. warning::
* *
......
...@@ -1358,11 +1358,6 @@ static int session_predicate_push_promise_send(nghttp2_session *session, ...@@ -1358,11 +1358,6 @@ static int session_predicate_push_promise_send(nghttp2_session *session,
assert(stream); assert(stream);
if (nghttp2_session_is_my_stream_id(session, stream->stream_id)) {
/* The associated stream must be initiated by the remote peer */
return NGHTTP2_ERR_PROTO;
}
if (session->remote_settings.enable_push == 0) { if (session->remote_settings.enable_push == 0) {
return NGHTTP2_ERR_PUSH_DISABLED; return NGHTTP2_ERR_PUSH_DISABLED;
} }
......
...@@ -247,7 +247,7 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_, ...@@ -247,7 +247,7 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags _U_,
int32_t promised_stream_id; int32_t promised_stream_id;
int rv; int rv;
if (stream_id == 0) { if (stream_id == 0 || nghttp2_session_is_my_stream_id(session, stream_id)) {
return NGHTTP2_ERR_INVALID_ARGUMENT; return NGHTTP2_ERR_INVALID_ARGUMENT;
} }
......
...@@ -4146,7 +4146,9 @@ void test_nghttp2_submit_invalid_nv(void) { ...@@ -4146,7 +4146,9 @@ void test_nghttp2_submit_invalid_nv(void) {
NULL)); NULL));
/* nghttp2_submit_push_promise */ /* nghttp2_submit_push_promise */
CU_ASSERT(0 < nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 2, open_stream(session, 1);
CU_ASSERT(0 < nghttp2_submit_push_promise(session, NGHTTP2_FLAG_NONE, 1,
empty_name_nv, empty_name_nv,
ARRLEN(empty_name_nv), NULL)); ARRLEN(empty_name_nv), 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