r1678 - trunk/varnish-cache/bin/varnishd

des at projects.linpro.no des at projects.linpro.no
Thu Jul 12 19:37:44 CEST 2007


Author: des
Date: 2007-07-12 19:37:44 +0200 (Thu, 12 Jul 2007)
New Revision: 1678

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
sockaddr.sa_len is not portable.


Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2007-07-12 16:02:47 UTC (rev 1677)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2007-07-12 17:37:44 UTC (rev 1678)
@@ -32,7 +32,10 @@
  */
 
 #include <sys/types.h>
+#include <sys/socket.h>
 
+#include <netinet/in.h>
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -480,8 +483,19 @@
 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);




More information about the varnish-commit mailing list