]> git.kaiwu.me - nginx.git/commitdiff
Upstream: fixed u->headers_in.headers allocation error handling.
authorSergey Kandaurov <pluknet@nginx.com>
Thu, 18 May 2017 11:17:00 +0000 (14:17 +0300)
committerSergey Kandaurov <pluknet@nginx.com>
Thu, 18 May 2017 11:17:00 +0000 (14:17 +0300)
Previously, an allocation error resulted in uninitialized memory access
when evaluating $upstream_http_ variables.

On a related note, see r->headers_out.headers cleanup work in 0cdee26605f3.

src/http/modules/ngx_http_fastcgi_module.c
src/http/modules/ngx_http_proxy_module.c
src/http/modules/ngx_http_scgi_module.c
src/http/modules/ngx_http_uwsgi_module.c

index 06c19738d268d1f89e30c4f8d980a615cc394178..741e5776850f83e5ce37c621b2aaf1b0bf218049 100644 (file)
@@ -1878,6 +1878,7 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
 
                     p = ngx_pnalloc(r->pool, size);
                     if (p == NULL) {
+                        h->hash = 0;
                         return NGX_ERROR;
                     }
 
@@ -1900,6 +1901,7 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
                         ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
                                       "invalid header after joining "
                                       "FastCGI records");
+                        h->hash = 0;
                         return NGX_ERROR;
                     }
 
@@ -1925,6 +1927,7 @@ ngx_http_fastcgi_process_header(ngx_http_request_t *r)
                                               h->key.len + 1 + h->value.len + 1
                                               + h->key.len);
                     if (h->key.data == NULL) {
+                        h->hash = 0;
                         return NGX_ERROR;
                     }
 
index 0fee2c2c41630046e6adb6c24f14717b5e12d4fe..839d479eaf6fe178b57d6871dbd7f93bdb299b27 100644 (file)
@@ -1798,6 +1798,7 @@ ngx_http_proxy_process_header(ngx_http_request_t *r)
             h->key.data = ngx_pnalloc(r->pool,
                                h->key.len + 1 + h->value.len + 1 + h->key.len);
             if (h->key.data == NULL) {
+                h->hash = 0;
                 return NGX_ERROR;
             }
 
index d1e37dde59515fbacd71a53734945cc9b63a444c..9204af47fe7150bb06bf9889937248d163ea8bdd 100644 (file)
@@ -1040,6 +1040,7 @@ ngx_http_scgi_process_header(ngx_http_request_t *r)
                                       h->key.len + 1 + h->value.len + 1
                                       + h->key.len);
             if (h->key.data == NULL) {
+                h->hash = 0;
                 return NGX_ERROR;
             }
 
index 26443bb4bc1dbdd4aaaeb78866956a02084d72f7..a2bec4c9b74c97d87b8b19e247dbb3d2acc604f6 100644 (file)
@@ -1244,6 +1244,7 @@ ngx_http_uwsgi_process_header(ngx_http_request_t *r)
                                       h->key.len + 1 + h->value.len + 1
                                       + h->key.len);
             if (h->key.data == NULL) {
+                h->hash = 0;
                 return NGX_ERROR;
             }