aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVladimir Homutov <vl@nginx.com>2013-07-11 19:50:19 +0400
committerVladimir Homutov <vl@nginx.com>2013-07-11 19:50:19 +0400
commitd79c8abcaafa70f7bac00c4f8ddd897e45475919 (patch)
tree14063c981a652d0e2faeb234e9100c2ad593ca3d /src
parentaf18946d769296d9efead825a0d1aa6a1a41fe74 (diff)
downloadnginx-d79c8abcaafa70f7bac00c4f8ddd897e45475919.tar.gz
nginx-d79c8abcaafa70f7bac00c4f8ddd897e45475919.zip
Core: fixed possible use of an uninitialized variable.
The call to ngx_sock_ntop() in ngx_connection_local_sockaddr() might be performed with the uninitialized "len" variable. The fix is to initialize variable to the size of corresponding socket address type. The issue was introduced in commit 05ba5bce31e0.
Diffstat (limited to 'src')
-rw-r--r--src/core/ngx_connection.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c
index 553a938f6..827be88db 100644
--- a/src/core/ngx_connection.c
+++ b/src/core/ngx_connection.c
@@ -1034,6 +1034,7 @@ ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
#if (NGX_HAVE_INET6)
case AF_INET6:
sin6 = (struct sockaddr_in6 *) c->local_sockaddr;
+ len = sizeof(struct sockaddr_in6);
for (addr = 0, i = 0; addr == 0 && i < 16; i++) {
addr |= sin6->sin6_addr.s6_addr[i];
@@ -1044,6 +1045,7 @@ ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
default: /* AF_INET */
sin = (struct sockaddr_in *) c->local_sockaddr;
+ len = sizeof(struct sockaddr_in);
addr = sin->sin_addr.s_addr;
break;
}