]> git.kaiwu.me - nginx.git/commitdiff
Realip: fixed uninitialized memory access.
authorRoman Arutyunyan <arut@nginx.com>
Thu, 1 Sep 2016 11:33:51 +0000 (14:33 +0300)
committerRoman Arutyunyan <arut@nginx.com>
Thu, 1 Sep 2016 11:33:51 +0000 (14:33 +0300)
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.

src/http/modules/ngx_http_realip_module.c

index 490a53d0e529a81ee822ced02a1785cc0c0208be..dba3c527b2008923560ca66b0241f0bb4cdc74f9 100644 (file)
@@ -264,7 +264,6 @@ ngx_http_realip_set_addr(ngx_http_request_t *r, ngx_addr_t *addr)
     }
 
     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_request_t *r, ngx_addr_t *addr)
     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;