[nginx] Autoindex: return NGX_ERROR on error if headers were sent.

Maxim Dounin mdounin at mdounin.ru
Tue Oct 8 12:12:32 UTC 2013


details:   http://hg.nginx.org/nginx/rev/5fa350899fe0
branches:  stable-1.4
changeset: 5414:5fa350899fe0
user:      Sergey Kandaurov <pluknet at nginx.com>
date:      Tue Jul 30 11:43:21 2013 +0400
description:
Autoindex: return NGX_ERROR on error if headers were sent.

This prevents ngx_http_finalize_request() from issuing
ngx_http_special_response_handler() on a freed context.

diffstat:

 src/http/modules/ngx_http_autoindex_module.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (21 lines):

diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -388,7 +388,7 @@ ngx_http_autoindex_handler(ngx_http_requ
 
     b = ngx_create_temp_buf(r->pool, len);
     if (b == NULL) {
-        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+        return NGX_ERROR;
     }
 
     if (entries.nelts > 1) {
@@ -649,7 +649,7 @@ ngx_http_autoindex_error(ngx_http_reques
                       ngx_close_dir_n " \"%V\" failed", name);
     }
 
-    return NGX_HTTP_INTERNAL_SERVER_ERROR;
+    return r->header_sent ? NGX_ERROR : NGX_HTTP_INTERNAL_SERVER_ERROR;
 }
 
 



More information about the nginx-devel mailing list