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

65cc5e
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
65cc5e
index 8c37854..90b10a8 100644
65cc5e
--- a/src/http/v2/ngx_http_v2.c
65cc5e
+++ b/src/http/v2/ngx_http_v2.c
65cc5e
@@ -245,6 +245,8 @@ ngx_http_v2_init(ngx_event_t *rev)
65cc5e
 
65cc5e
     h2scf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_v2_module);
65cc5e
 
65cc5e
+    h2c->priority_limit = h2scf->concurrent_streams;
65cc5e
+
65cc5e
     h2c->pool = ngx_create_pool(h2scf->pool_size, h2c->connection->log);
65cc5e
     if (h2c->pool == NULL) {
65cc5e
         ngx_http_close_connection(c);
65cc5e
@@ -1763,6 +1765,13 @@ ngx_http_v2_state_priority(ngx_http_v2_connection_t *h2c, u_char *pos,
65cc5e
         return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_SIZE_ERROR);
65cc5e
     }
65cc5e
 
65cc5e
+    if (--h2c->priority_limit == 0) {
65cc5e
+        ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
65cc5e
+                      "client sent too many PRIORITY frames");
65cc5e
+
65cc5e
+        return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM);
65cc5e
+    }
65cc5e
+
65cc5e
     if (end - pos < NGX_HTTP_V2_PRIORITY_SIZE) {
65cc5e
         return ngx_http_v2_state_save(h2c, pos, end,
65cc5e
                                       ngx_http_v2_state_priority);
65cc5e
@@ -2821,6 +2830,8 @@ ngx_http_v2_create_stream(ngx_http_v2_connection_t *h2c)
65cc5e
 
65cc5e
     h2c->processing++;
65cc5e
 
65cc5e
+    h2c->priority_limit += h2scf->concurrent_streams;
65cc5e
+
65cc5e
     return stream;
65cc5e
 }
65cc5e
 
65cc5e
diff --git a/src/http/v2/ngx_http_v2.h b/src/http/v2/ngx_http_v2.h
65cc5e
index 112779e..8e56ee5 100644
65cc5e
--- a/src/http/v2/ngx_http_v2.h
65cc5e
+++ b/src/http/v2/ngx_http_v2.h
65cc5e
@@ -116,6 +116,7 @@ struct ngx_http_v2_connection_s {
65cc5e
 
65cc5e
     ngx_uint_t                       processing;
65cc5e
     ngx_uint_t                       frames;
65cc5e
+    ngx_uint_t                       priority_limit;
65cc5e
 
65cc5e
     size_t                           send_window;
65cc5e
     size_t                           recv_window;