From 578d5ac5628d8154ebcea3edf3f0fb5e748e47c8 Mon Sep 17 00:00:00 2001 From: des Date: Thu, 12 Jul 2007 17:37:44 +0000 Subject: [PATCH] sockaddr.sa_len is not portable. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1678 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_vrt.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index 612a7d5c..6437f705 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -32,6 +32,9 @@ */ #include +#include + +#include #include #include @@ -480,8 +483,19 @@ char * VRT_IP_string(struct sess *sp, struct sockaddr *sa) { char h[64], p[8], *q; + socklen_t len = 0; - TCP_name(sa, sa->sa_len, h, sizeof h, p, sizeof p); + /* XXX can't rely on sockaddr.sa_len */ + switch (sa->sa_family) { + case AF_INET: + len = sizeof(struct sockaddr_in); + break; + case AF_INET6: + len = sizeof(struct sockaddr_in6); + break; + } + XXXAN(len); + TCP_name(sa, len, h, sizeof h, p, sizeof p); q = WS_Alloc(sp->http->ws, strlen(h) + strlen(p) + 2); AN(q); strcpy(q, h); -- 2.39.5