[PATCH] Always use default server configs for large buffers allocation

Daniil Bondarev xonatius at gmail.com
Fri Feb 17 01:00:20 UTC 2017


# HG changeset patch
# User Daniil Bondarev <bondarev at amazon.com>
# Date 1485286710 28800
#      Tue Jan 24 11:38:30 2017 -0800
# Node ID 8cd694e06443aaa1ed0601108681fa1c6f7297e0
# Parent  d84f48e571e449ee6c072a8d52cdea8e06b88ef7
Always use default server configs for large buffers allocation

Single http connection can flip between default server and virtual
servers: depending on parsed Host header for a current request nginx
changes current request configs. Currently this behavior might cause
buffer overrun while adding new buffer to hc->busy, if hc->busy was
allocated with config containing fewer large_client_header_buffers than
the current one.

This change makes nginx to always use large_client_header_buffers from
http_connection config, which is default server config.

diff -r d84f48e571e4 -r 8cd694e06443 src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c Tue Jan 24 17:02:19 2017 +0300
+++ b/src/http/ngx_http_request.c Tue Jan 24 11:38:30 2017 -0800
@@ -1447,7 +1447,9 @@ ngx_http_alloc_large_header_buffer(ngx_h

     old = request_line ? r->request_start : r->header_name_start;

-    cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
+    hc = r->http_connection;
+
+    cscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_core_module);

     if (r->state != 0
         && (size_t) (r->header_in->pos - old)
@@ -1456,8 +1458,6 @@ ngx_http_alloc_large_header_buffer(ngx_h
         return NGX_DECLINED;
     }

-    hc = r->http_connection;
-
     if (hc->nfree) {
         b = hc->free[--hc->nfree];


More information about the nginx-devel mailing list