aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_static_module.c
diff options
context:
space:
mode:
authorSergey Kandaurov <pluknet@nginx.com>2017-04-20 18:26:37 +0300
committerSergey Kandaurov <pluknet@nginx.com>2017-04-20 18:26:37 +0300
commit9ecf8428645579cf66adc5ba939bf1267924c5bc (patch)
treebffebdeaec5665d8c6e1c128cffb6f9287773d2a /src/http/modules/ngx_http_static_module.c
parent30e26a8c57fab4b7d95eacc7fd5c0bae23364529 (diff)
downloadnginx-9ecf8428645579cf66adc5ba939bf1267924c5bc.tar.gz
nginx-9ecf8428645579cf66adc5ba939bf1267924c5bc.zip
Cleaned up r->headers_out.headers allocation error handling.
If initialization of a header failed for some reason after ngx_list_push(), leaving the header as is can result in uninitialized memory access by the header filter or the log module. The fix is to clear partially initialized headers in case of errors. For the Cache-Control header, the fix is to postpone pushing r->headers_out.cache_control until its value is completed.
Diffstat (limited to 'src/http/modules/ngx_http_static_module.c')
-rw-r--r--src/http/modules/ngx_http_static_module.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_static_module.c b/src/http/modules/ngx_http_static_module.c
index b0513be1c..0e16c05a5 100644
--- a/src/http/modules/ngx_http_static_module.c
+++ b/src/http/modules/ngx_http_static_module.c
@@ -169,6 +169,7 @@ ngx_http_static_handler(ngx_http_request_t *r)
location = ngx_pnalloc(r->pool, len);
if (location == NULL) {
+ ngx_http_clear_location(r);
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}