Check stream_id is nonzero for DATA, HEADERS, PRIORITY, RST_STREAM, PUSH_PROMISE
This commit is contained in:
parent
bfaab30733
commit
19729962a3
|
@ -2231,6 +2231,8 @@ int32_t nghttp2_submit_request(nghttp2_session *session,
|
|||
*
|
||||
* :enum:`NGHTTP2_ERR_NOMEM`
|
||||
* Out of memory.
|
||||
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
|
||||
* The |stream_id| is 0.
|
||||
*/
|
||||
int nghttp2_submit_response(nghttp2_session *session,
|
||||
int32_t stream_id,
|
||||
|
@ -2297,6 +2299,8 @@ int nghttp2_submit_response(nghttp2_session *session,
|
|||
* :enum:`NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE`
|
||||
* No stream ID is available because maximum stream ID was
|
||||
* reached.
|
||||
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
|
||||
* The |stream_id| is 0.
|
||||
*
|
||||
* .. warning::
|
||||
*
|
||||
|
@ -2332,6 +2336,8 @@ int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
|
|||
* Out of memory.
|
||||
* :enum:`NGHTTP2_ERR_DATA_EXIST`
|
||||
* DATA has been already submitted and not fully processed yet.
|
||||
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
|
||||
* The |stream_id| is 0.
|
||||
*/
|
||||
int nghttp2_submit_data(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id,
|
||||
|
@ -2363,7 +2369,8 @@ int nghttp2_submit_data(nghttp2_session *session, uint8_t flags,
|
|||
* :enum:`NGHTTP2_ERR_NOMEM`
|
||||
* Out of memory.
|
||||
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
|
||||
* The |pri_spec| is NULL; or trying to depend on itself.
|
||||
* The |stream_id| is 0; or the |pri_spec| is NULL; or trying to
|
||||
* depend on itself.
|
||||
*/
|
||||
int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id,
|
||||
|
@ -2383,6 +2390,8 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
|
|||
*
|
||||
* :enum:`NGHTTP2_ERR_NOMEM`
|
||||
* Out of memory.
|
||||
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
|
||||
* The |stream_id| is 0.
|
||||
*/
|
||||
int nghttp2_submit_rst_stream(nghttp2_session *session, uint8_t flags,
|
||||
int32_t stream_id,
|
||||
|
@ -2466,6 +2475,8 @@ int nghttp2_submit_settings(nghttp2_session *session, uint8_t flags,
|
|||
* :enum:`NGHTTP2_ERR_STREAM_ID_NOT_AVAILABLE`
|
||||
* No stream ID is available because maximum stream ID was
|
||||
* reached.
|
||||
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
|
||||
* The |stream_id| is 0.
|
||||
*
|
||||
* .. warning::
|
||||
*
|
||||
|
|
|
@ -52,6 +52,11 @@ static int32_t submit_headers_shared
|
|||
nghttp2_headers_aux_data *aux_data = NULL;
|
||||
nghttp2_headers_category hcat;
|
||||
|
||||
if(stream_id == 0) {
|
||||
rv = NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if(data_prd != NULL && data_prd->read_callback != NULL) {
|
||||
data_prd_copy = malloc(sizeof(nghttp2_data_provider));
|
||||
if(data_prd_copy == NULL) {
|
||||
|
@ -197,7 +202,7 @@ int nghttp2_submit_priority(nghttp2_session *session, uint8_t flags,
|
|||
nghttp2_frame *frame;
|
||||
nghttp2_priority_spec copy_pri_spec;
|
||||
|
||||
if(pri_spec == NULL) {
|
||||
if(stream_id == 0 || pri_spec == NULL) {
|
||||
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
|
@ -233,6 +238,10 @@ int nghttp2_submit_rst_stream(nghttp2_session *session, uint8_t flags,
|
|||
int32_t stream_id,
|
||||
nghttp2_error_code error_code)
|
||||
{
|
||||
if(stream_id == 0) {
|
||||
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return nghttp2_session_add_rst_stream(session, stream_id, error_code);
|
||||
}
|
||||
|
||||
|
@ -262,6 +271,10 @@ int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags,
|
|||
int32_t promised_stream_id;
|
||||
int rv;
|
||||
|
||||
if(stream_id == 0) {
|
||||
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if(!session->server) {
|
||||
return NGHTTP2_ERR_PROTO;
|
||||
}
|
||||
|
@ -495,6 +508,10 @@ int nghttp2_submit_data(nghttp2_session *session, uint8_t flags,
|
|||
uint8_t nflags = flags & (NGHTTP2_FLAG_END_STREAM |
|
||||
NGHTTP2_FLAG_END_SEGMENT);
|
||||
|
||||
if(stream_id == 0) {
|
||||
return NGHTTP2_ERR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
data_frame = malloc(sizeof(nghttp2_private_data));
|
||||
if(data_frame == NULL) {
|
||||
return NGHTTP2_ERR_NOMEM;
|
||||
|
|
Loading…
Reference in New Issue