changeset 6671:6b1b8c4b7a95

Realip: fixed uninitialized memory access. Previously, the realip module could be left with uninitialized context after an error in the ngx_http_realip_set_addr() function. That context could be later accessed by $realip_remote_addr and $realip_remote_port variable handlers.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 01 Sep 2016 14:33:51 +0300
parents c6372a40c2a7
children 0fa883e92895
files src/http/modules/ngx_http_realip_module.c
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -264,7 +264,6 @@ ngx_http_realip_set_addr(ngx_http_reques
     }
 
     ctx = cln->data;
-    ngx_http_set_ctx(r, ctx, ngx_http_realip_module);
 
     c = r->connection;
 
@@ -282,6 +281,7 @@ ngx_http_realip_set_addr(ngx_http_reques
     ngx_memcpy(p, text, len);
 
     cln->handler = ngx_http_realip_cleanup;
+    ngx_http_set_ctx(r, ctx, ngx_http_realip_module);
 
     ctx->connection = c;
     ctx->sockaddr = c->sockaddr;