diff --git a/include/ngx_http_push_stream_module_utils.h b/include/ngx_http_push_stream_module_utils.h index 904c697..81beeee 100644 --- a/include/ngx_http_push_stream_module_utils.h +++ b/include/ngx_http_push_stream_module_utils.h @@ -259,7 +259,7 @@ static ngx_int_t ngx_http_push_stream_memory_cleanup(void); ngx_chain_t * ngx_http_push_stream_get_buf(ngx_http_request_t *r); static void ngx_http_push_stream_unescape_uri(ngx_str_t *value); -static void ngx_http_push_stream_complex_value(ngx_http_request_t *r, ngx_http_complex_value_t *val, ngx_str_t *value); +static ngx_int_t ngx_http_push_stream_complex_value(ngx_http_request_t *r, ngx_http_complex_value_t *val, ngx_str_t *value); ngx_int_t ngx_http_push_stream_add_msg_to_channel(ngx_http_push_stream_main_conf_t *mcf, ngx_log_t *log, ngx_http_push_stream_channel_t *channel, u_char *text, size_t len, ngx_str_t *event_id, ngx_str_t *event_type, ngx_flag_t store_messages, ngx_pool_t *temp_pool); diff --git a/src/ngx_http_push_stream_module_publisher.c b/src/ngx_http_push_stream_module_publisher.c index d078859..758f082 100644 --- a/src/ngx_http_push_stream_module_publisher.c +++ b/src/ngx_http_push_stream_module_publisher.c @@ -43,7 +43,11 @@ ngx_http_push_stream_publisher_handler(ngx_http_request_t *r) if (cf->allowed_origins != NULL) { - ngx_http_push_stream_complex_value(r, cf->allowed_origins, &vv_allowed_origins); + if (ngx_http_push_stream_complex_value(r, cf->allowed_origins, &vv_allowed_origins) != NGX_OK) + { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: failed to push complex value cf->allowed_origin"); + return NGX_ERROR; + } } if (vv_allowed_origins.len > 0) { diff --git a/src/ngx_http_push_stream_module_subscriber.c b/src/ngx_http_push_stream_module_subscriber.c index d683360..7be984e 100644 --- a/src/ngx_http_push_stream_module_subscriber.c +++ b/src/ngx_http_push_stream_module_subscriber.c @@ -651,7 +651,11 @@ ngx_http_push_stream_get_padding_by_user_agent(ngx_http_request_t *r) ngx_str_t vv_user_agent = ngx_null_string; if (cf->user_agent != NULL) { - ngx_http_push_stream_complex_value(r, cf->user_agent, &vv_user_agent); + if (ngx_http_push_stream_complex_value(r, cf->user_agent, &vv_user_agent) != NGX_OK) + { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: failed to push complex value cf->user_agent"); + return NULL; + } } else if (r->headers_in.user_agent != NULL) { vv_user_agent = r->headers_in.user_agent->value; } diff --git a/src/ngx_http_push_stream_module_utils.c b/src/ngx_http_push_stream_module_utils.c index fdc2961..4d0a0b3 100644 --- a/src/ngx_http_push_stream_module_utils.c +++ b/src/ngx_http_push_stream_module_utils.c @@ -1857,14 +1857,23 @@ ngx_http_push_stream_get_last_received_message_values(ngx_http_request_t *r, tim ngx_str_t vv_event_id = ngx_null_string, vv_time = ngx_null_string; if (cf->last_received_message_time != NULL) { - ngx_http_push_stream_complex_value(r, cf->last_received_message_time, &vv_time); + if (ngx_http_push_stream_complex_value(r, cf->last_received_message_time, &vv_time) != NGX_OK) + { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: failed to push stream complex value cf->last_receieved_message_time"); + } } else if (r->headers_in.if_modified_since != NULL) { vv_time = r->headers_in.if_modified_since->value; } if (cf->last_received_message_tag != NULL) { - ngx_http_push_stream_complex_value(r, cf->last_received_message_tag, &vv_etag); - etag = vv_etag.len ? &vv_etag : NULL; + if (ngx_http_push_stream_complex_value(r, cf->last_received_message_tag, &vv_etag) != NGX_OK) + { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: failed to push stream complex value cf->last_receieved_message_tag"); + } + else + { + etag = vv_etag.len ? &vv_etag : NULL; + } } else { etag = ngx_http_push_stream_get_header(r, &NGX_HTTP_PUSH_STREAM_HEADER_IF_NONE_MATCH); } @@ -1875,12 +1884,17 @@ ngx_http_push_stream_get_last_received_message_values(ngx_http_request_t *r, tim } if (cf->last_event_id != NULL) { - ngx_http_push_stream_complex_value(r, cf->last_event_id, &vv_event_id); - if (vv_event_id.len) { - *last_event_id = ngx_http_push_stream_create_str(ctx->temp_pool, vv_event_id.len); - ngx_memcpy(((ngx_str_t *)*last_event_id)->data, vv_event_id.data, vv_event_id.len); - } - } else { + if (ngx_http_push_stream_complex_value(r, cf->last_event_id, &vv_event_id) == NGX_OK) { + if (vv_event_id.len) { + *last_event_id = ngx_http_push_stream_create_str(ctx->temp_pool, vv_event_id.len); + ngx_memcpy(((ngx_str_t *)*last_event_id)->data, vv_event_id.data, vv_event_id.len); + } + else { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: failed to push stream complex value cf->last_event_id"); + } + } + } + else { *last_event_id = ngx_http_push_stream_get_header(r, &NGX_HTTP_PUSH_STREAM_HEADER_LAST_EVENT_ID); } @@ -2116,11 +2130,15 @@ ngx_http_push_stream_parse_paddings(ngx_conf_t *cf, ngx_str_t *paddings_by_user } -static void +static ngx_int_t ngx_http_push_stream_complex_value(ngx_http_request_t *r, ngx_http_complex_value_t *val, ngx_str_t *value) { - ngx_http_complex_value(r, val, value); - ngx_http_push_stream_unescape_uri(value); + if (ngx_http_complex_value(r, val, value) != NGX_OK) + { + return NGX_ERROR; + } + ngx_http_push_stream_unescape_uri(value); + return NGX_OK; } @@ -2299,7 +2317,12 @@ ngx_http_push_stream_parse_channels_ids_from_path(ngx_http_request_t *r, ngx_poo int captures[15]; ngx_int_t n; - ngx_http_push_stream_complex_value(r, cf->channels_path, &vv_channels_path); + if (ngx_http_push_stream_complex_value(r, cf->channels_path, &vv_channels_path)) + { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "push stream module: failed to push stream complex value cf->channels_path"); + return NULL; + } + if (vv_channels_path.len == 0) { return NULL; }