[nginx] Postpone filter: prevented uninitialized r->out.

Roman Arutyunyan arut at nginx.com
Thu Mar 1 16:13:04 UTC 2018


details:   http://hg.nginx.org/nginx/rev/43585e0e12a3
branches:  
changeset: 7221:43585e0e12a3
user:      Roman Arutyunyan <arut at nginx.com>
date:      Thu Mar 01 18:38:39 2018 +0300
description:
Postpone filter: prevented uninitialized r->out.

The r->out chain link could be left uninitialized in case of error.
A segfault could happen if the subrequest handler accessed it.
The issue was introduced in commit 20f139e9ffa8.

diffstat:

 src/http/ngx_http_postpone_filter_module.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (27 lines):

diff -r 20f139e9ffa8 -r 43585e0e12a3 src/http/ngx_http_postpone_filter_module.c
--- a/src/http/ngx_http_postpone_filter_module.c	Wed Feb 28 16:56:58 2018 +0300
+++ b/src/http/ngx_http_postpone_filter_module.c	Thu Mar 01 18:38:39 2018 +0300
@@ -191,11 +191,6 @@ ngx_http_postpone_filter_in_memory(ngx_h
                    "http postpone filter in memory");
 
     if (r->out == NULL) {
-        r->out = ngx_alloc_chain_link(r->pool);
-        if (r->out == NULL) {
-            return NGX_ERROR;
-        }
-
         clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
         if (r->headers_out.content_length_n != -1) {
@@ -218,6 +213,11 @@ ngx_http_postpone_filter_in_memory(ngx_h
 
         b->last_buf = 1;
 
+        r->out = ngx_alloc_chain_link(r->pool);
+        if (r->out == NULL) {
+            return NGX_ERROR;
+        }
+
         r->out->buf = b;
         r->out->next = NULL;
     }


More information about the nginx-devel mailing list