summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-06-27 20:06:59 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-06-27 20:06:59 +0300
commit2006e9f537ba327d89e546188fbcf81307ce3551 (patch)
treebeed8ecb56219fd0c96725a251387356e4af1636 /src
parentcf3e714c3905bcb532c1cb95de72dec311418f5c (diff)
downloadunit-2006e9f537ba327d89e546188fbcf81307ce3551.tar.gz
unit-2006e9f537ba327d89e546188fbcf81307ce3551.tar.bz2
Fixed INET6 sockaddr processing in nxt_sockaddr_text().
Diffstat (limited to 'src')
-rw-r--r--src/nxt_sockaddr.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/nxt_sockaddr.c b/src/nxt_sockaddr.c
index 70bdfa06..4119fe8c 100644
--- a/src/nxt_sockaddr.c
+++ b/src/nxt_sockaddr.c
@@ -222,7 +222,7 @@ nxt_sockaddr_text(nxt_sockaddr_t *sa)
offset = offsetof(nxt_sockaddr_t, u) + sizeof(struct sockaddr_in6);
sa->start = offset;
- sa->address_start = offset;
+ sa->address_start = offset + 1;
start = nxt_pointer_to(sa, offset);
p = start;
@@ -479,11 +479,14 @@ nxt_sockaddr_ntop(nxt_sockaddr_t *sa, u_char *buf, u_char *end, nxt_bool_t port)
static u_char *
nxt_inet6_ntop(u_char *addr, u_char *buf, u_char *end)
{
- u_char *p;
- size_t zero_groups, last_zero_groups, ipv6_bytes;
- nxt_uint_t i, zero_start, last_zero_start;
+ u_char *p;
+ size_t zero_groups, last_zero_groups, ipv6_bytes;
+ nxt_uint_t i, zero_start, last_zero_start;
+
+ const size_t max_inet6_length =
+ sizeof("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff") - 1;
- if (buf + NXT_INET6_ADDR_STR_LEN > end) {
+ if (buf + max_inet6_length > end) {
return buf;
}