Blame SOURCES/nginx-1.12.1-CVE-2019-9513.patch

1ba31c
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
1ba31c
index 8b5975c..9e12243 100644
1ba31c
--- a/src/http/v2/ngx_http_v2.c
1ba31c
+++ b/src/http/v2/ngx_http_v2.c
1ba31c
@@ -247,6 +247,8 @@ ngx_http_v2_init(ngx_event_t *rev)
1ba31c
 
1ba31c
     h2scf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v2_module);
1ba31c
 
1ba31c
+    h2c->priority_limit = h2scf->concurrent_streams;
1ba31c
+
1ba31c
     h2c->pool = ngx_create_pool(h2scf->pool_size, h2c->connection->log);
1ba31c
     if (h2c->pool == NULL) {
1ba31c
         ngx_http_close_connection(c);
1ba31c
@@ -1786,6 +1788,13 @@ ngx_http_v2_state_priority(ngx_http_v2_connection_t *h2c, u_char *pos,
1ba31c
         return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR);
1ba31c
     }
1ba31c
 
1ba31c
+    if (--h2c->priority_limit == 0) {
1ba31c
+        ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
1ba31c
+                      "client sent too many PRIORITY frames");
1ba31c
+
1ba31c
+        return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM);
1ba31c
+    }
1ba31c
+
1ba31c
     if (end - pos < NGX_HTTP_V2_PRIORITY_SIZE) {
1ba31c
         return ngx_http_v2_state_save(h2c, pos, end,
1ba31c
                                       ngx_http_v2_state_priority);
1ba31c
@@ -2846,6 +2855,8 @@ ngx_http_v2_create_stream(ngx_http_v2_connection_t *h2c)
1ba31c
 
1ba31c
     h2c->processing++;
1ba31c
 
1ba31c
+    h2c->priority_limit += h2scf->concurrent_streams;
1ba31c
+
1ba31c
     return stream;
1ba31c
 }
1ba31c
 
1ba31c
diff --git a/src/http/v2/ngx_http_v2.h b/src/http/v2/ngx_http_v2.h
1ba31c
index 282de8f..4a74a6a 100644
1ba31c
--- a/src/http/v2/ngx_http_v2.h
1ba31c
+++ b/src/http/v2/ngx_http_v2.h
1ba31c
@@ -117,6 +117,7 @@ struct ngx_http_v2_connection_s {
1ba31c
     ngx_uint_t                       processing;
1ba31c
     ngx_uint_t                       frames;
1ba31c
     ngx_uint_t                       idle;
1ba31c
+    ngx_uint_t                       priority_limit;
1ba31c
 
1ba31c
     size_t                           send_window;
1ba31c
     size_t                           recv_window;