[master] 05356fb7c varnishd: VTCP_name() is not for UDS

Nils Goroll nils.goroll at uplex.de
Mon Jan 11 12:27:06 UTC 2021

commit 05356fb7c6c10d3ddd9766f474da679046922422
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Jan 11 13:18:09 2021 +0100

    varnishd: VTCP_name() is not for UDS
    fixes a regression introduced by c1352b0b0ece8028317c838751d9042a55347cd5:
    by not using a suckaddr, VTCP_myname() would also work on UDS, but none
    of the VTCP was ever intended to (and there are other places where that
    is asserted). So one could argue that 9837045a011db7496b6a0680687c48fbbac41186
    was already wrong, but I do not want to deflect from my own mistake in
    any way.
    Fixes #3492

diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c
index d638a9f8e..cd99c9b76 100644
--- a/bin/varnishd/cache/cache_backend_probe.c
+++ b/bin/varnishd/cache/cache_backend_probe.c
@@ -258,16 +258,17 @@ vbp_write_proxy_v1(struct vbp_target *vt, int *sock)
 	sua = VSA_getsockname(*sock, vsabuf, sizeof vsabuf);
-	VTCP_name(sua, addr, sizeof addr, port, sizeof port);
 	AN(VSB_init(&vsb, buf, sizeof buf));
 	proto = VSA_Get_Proto(sua);
-	if (proto == AF_INET || proto == AF_INET6)
+	if (proto == AF_INET || proto == AF_INET6) {
+		VTCP_name(sua, addr, sizeof addr, port, sizeof port);
 		VSB_printf(&vsb, "PROXY %s %s %s %s %s\r\n",
 		    proto == AF_INET ? "TCP4" : "TCP6",
 		    addr, addr, port, port);
-	else
+	} else {
 		VSB_cat(&vsb, "PROXY UNKNOWN\r\n");
+	}
diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c
index 84832cb65..e56cd3ba9 100644
--- a/lib/libvarnish/vtcp.c
+++ b/lib/libvarnish/vtcp.c
@@ -100,6 +100,7 @@ VTCP_name(const struct suckaddr *addr, char *abuf, unsigned alen,
 	socklen_t sl;
 	sa = VSA_Get_Sockaddr(addr, &sl);
+	AN(sa);
 	vtcp_sa_to_ascii(sa, sl, abuf, alen, pbuf, plen);

More information about the varnish-commit mailing list