changeset 4050:36d2cd2e361d stable-1.0

Merge of r4016: Fix ignored headers handling in fastcgi/scgi/uwsgi. The bug had appeared in r3561 (fastcgi), r3638 (scgi), r3567 (uwsgi).
author Igor Sysoev <igor@sysoev.ru>
date Mon, 29 Aug 2011 14:13:46 +0000
parents 01855743e3f6
children 23166b41f9b3
files src/http/modules/ngx_http_fastcgi_module.c src/http/modules/ngx_http_scgi_module.c src/http/modules/ngx_http_uwsgi_module.c
diffstat 3 files changed, 27 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -737,7 +737,15 @@ ngx_http_fastcgi_create_request(ngx_http
         lowcase_key = NULL;
 
         if (flcf->header_params) {
-            ignored = ngx_palloc(r->pool, flcf->header_params * sizeof(void *));
+            n = 0;
+            part = &r->headers_in.headers.part;
+
+            while (part) {
+                n += part->nelts;
+                part = part->next;
+            }
+
+            ignored = ngx_palloc(r->pool, n * sizeof(void *));
             if (ignored == NULL) {
                 return NGX_ERROR;
             }
--- a/src/http/modules/ngx_http_scgi_module.c
+++ b/src/http/modules/ngx_http_scgi_module.c
@@ -561,7 +561,15 @@ ngx_http_scgi_create_request(ngx_http_re
         lowcase_key = NULL;
 
         if (scf->header_params) {
-            ignored = ngx_palloc(r->pool, scf->header_params * sizeof(void *));
+            n = 0;
+            part = &r->headers_in.headers.part;
+
+            while (part) {
+                n += part->nelts;
+                part = part->next;
+            }
+
+            ignored = ngx_palloc(r->pool, n * sizeof(void *));
             if (ignored == NULL) {
                 return NGX_ERROR;
             }
--- a/src/http/modules/ngx_http_uwsgi_module.c
+++ b/src/http/modules/ngx_http_uwsgi_module.c
@@ -589,7 +589,15 @@ ngx_http_uwsgi_create_request(ngx_http_r
         lowcase_key = NULL;
 
         if (uwcf->header_params) {
-            ignored = ngx_palloc(r->pool, uwcf->header_params * sizeof(void *));
+            n = 0;
+            part = &r->headers_in.headers.part;
+
+            while (part) {
+                n += part->nelts;
+                part = part->next;
+            }
+
+            ignored = ngx_palloc(r->pool, n * sizeof(void *));
             if (ignored == NULL) {
                 return NGX_ERROR;
             }