Mercurial > hg > nginx
comparison src/http/modules/ngx_http_realip_module.c @ 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 | b3b7e33083ac |
children | cecf415643d7 |
comparison
equal
deleted
inserted
replaced
6670:c6372a40c2a7 | 6671:6b1b8c4b7a95 |
---|---|
262 if (cln == NULL) { | 262 if (cln == NULL) { |
263 return NGX_HTTP_INTERNAL_SERVER_ERROR; | 263 return NGX_HTTP_INTERNAL_SERVER_ERROR; |
264 } | 264 } |
265 | 265 |
266 ctx = cln->data; | 266 ctx = cln->data; |
267 ngx_http_set_ctx(r, ctx, ngx_http_realip_module); | |
268 | 267 |
269 c = r->connection; | 268 c = r->connection; |
270 | 269 |
271 len = ngx_sock_ntop(addr->sockaddr, addr->socklen, text, | 270 len = ngx_sock_ntop(addr->sockaddr, addr->socklen, text, |
272 NGX_SOCKADDR_STRLEN, 0); | 271 NGX_SOCKADDR_STRLEN, 0); |
280 } | 279 } |
281 | 280 |
282 ngx_memcpy(p, text, len); | 281 ngx_memcpy(p, text, len); |
283 | 282 |
284 cln->handler = ngx_http_realip_cleanup; | 283 cln->handler = ngx_http_realip_cleanup; |
284 ngx_http_set_ctx(r, ctx, ngx_http_realip_module); | |
285 | 285 |
286 ctx->connection = c; | 286 ctx->connection = c; |
287 ctx->sockaddr = c->sockaddr; | 287 ctx->sockaddr = c->sockaddr; |
288 ctx->socklen = c->socklen; | 288 ctx->socklen = c->socklen; |
289 ctx->addr_text = c->addr_text; | 289 ctx->addr_text = c->addr_text; |