diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-10-19 17:22:33 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-10-19 17:22:33 +0300 |
commit | 0833074f304e0b9e973510ebc8f29505bb84a41d (patch) | |
tree | b9caac36200aa183b244b804ade3ca075944a41b | |
parent | 3c6edead2562450861cc938268f4a848b7e4deab (diff) | |
download | unit-0833074f304e0b9e973510ebc8f29505bb84a41d.tar.gz unit-0833074f304e0b9e973510ebc8f29505bb84a41d.tar.bz2 |
Fixed the bug introduced in the previous changeset.
-rw-r--r-- | src/nxt_router.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c index 1e58a589..155d1dff 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -3016,7 +3016,7 @@ static nxt_sockaddr_t * nxt_router_local_addr(nxt_task_t *task, nxt_conn_t *c) { int ret; - size_t size; + size_t size, length; socklen_t socklen; nxt_sockaddr_t *sa; @@ -3030,13 +3030,15 @@ nxt_router_local_addr(nxt_task_t *task, nxt_conn_t *c) #if (NXT_INET6) case AF_INET6: socklen = sizeof(struct sockaddr_in6); - size = offsetof(nxt_sockaddr_t, u) + socklen + NXT_INET6_ADDR_STR_LEN; + length = NXT_INET6_ADDR_STR_LEN; + size = offsetof(nxt_sockaddr_t, u) + socklen + length; break; #endif case AF_INET: default: - socklen = sizeof(struct sockaddr_in6); - size = offsetof(nxt_sockaddr_t, u) + socklen + NXT_INET_ADDR_STR_LEN; + socklen = sizeof(struct sockaddr_in); + length = NXT_INET_ADDR_STR_LEN; + size = offsetof(nxt_sockaddr_t, u) + socklen + length; break; } @@ -3045,6 +3047,9 @@ nxt_router_local_addr(nxt_task_t *task, nxt_conn_t *c) return NULL; } + sa->socklen = socklen; + sa->length = length; + ret = getsockname(c->socket.fd, &sa->u.sockaddr, &socklen); if (nxt_slow_path(ret != 0)) { nxt_log(task, NXT_LOG_CRIT, "getsockname(%d) failed", c->socket.fd); |