[master] e95740a Fix an issue in the VCC generated code related to constant IP#.

Poul-Henning Kamp phk at varnish-cache.org
Tue Nov 12 20:18:12 CET 2013


commit e95740ad86926292ba8965c54b9efd17f0e36f89
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Nov 12 19:17:45 2013 +0000

    Fix an issue in the VCC generated code related to constant IP#.

diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c
index e756360..9a9ed2a 100644
--- a/lib/libvcc/vcc_utils.c
+++ b/lib/libvcc/vcc_utils.c
@@ -108,17 +108,19 @@ vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal)
 	sua = VSA_Malloc(sa, sal);
 	AN(sua);
 
-	p = TlAlloc(tl, 20);
-	AN(p);
-	sprintf(p, "sockaddr_%u", tl->unique++);
-
 	Fh(tl, 0, "static const unsigned long long");
-	Fh(tl, 0, " %s[%d] = {\n", p, n);
+	Fh(tl, 0, " sockaddr_%u[%d] = {\n", tl->unique, n);
 	memcpy(b, sua, vsa_suckaddr_len);
 	free(sua);
 	for (len = 0; len < n; len++)
 		Fh(tl, 0, "%s    0x%016llx", len ? ",\n" : "", b[len]);
 	Fh(tl, 0, "\n};\n");
+
+	p = TlAlloc(tl, 40);
+	AN(p);
+	sprintf(p, "(const void*)sockaddr_%u", tl->unique);
+
+	tl->unique++;
 	return (p);
 }
 
@@ -229,7 +231,7 @@ Resolve_Sockaddr(struct vcc *tl,
 		}
 
 		pp->l =  res->ai_addrlen;
-		assert(pp->l < sizeof(struct sockaddr_storage));
+		assert(pp->l <= sizeof(struct sockaddr_storage));
 		memcpy(&pp->sa, res->ai_addr, pp->l);
 
 		error = getnameinfo(res->ai_addr, res->ai_addrlen,
@@ -238,9 +240,8 @@ Resolve_Sockaddr(struct vcc *tl,
 
 		Fh(tl, 0, "\n/* \"%s\" -> %s */\n", host, hbuf);
 		*(pp->dst) = vcc_sockaddr(tl, &pp->sa, pp->l);
-		if (pp->dst_ascii != NULL) {
+		if (pp->dst_ascii != NULL)
 			*pp->dst_ascii = TlDup(tl, hbuf);
-		}
 		retval++;
 	}
 	if (p_ascii != NULL) {



More information about the varnish-commit mailing list