From ffbfd0935a4a75c4e3418f1010d526fbd93139a3 Mon Sep 17 00:00:00 2001 From: jacob Date: Mon, 5 Jan 2009 23:36:14 +0000 Subject: [PATCH] sk_address_is_local() failed to cope when presented with a Unix-domain socket. This could cause Unix PuTTY to segfault when X forwarding over an SSH session through a proxy. (sk_getaddr() wouldn't cope either -- in that case, add an assertion to make it more obvious; I don't think it should ever happen.) git-svn-id: svn://svn.tartarus.org/sgt/putty@8391 cda61777-01e9-0310-a592-d414129be87e --- unix/uxnet.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unix/uxnet.c b/unix/uxnet.c index 96d3aa51..8e95a65e 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -301,7 +301,9 @@ static int sk_nextaddr(SockAddr addr, SockAddrStep *step) void sk_getaddr(SockAddr addr, char *buf, int buflen) { - + /* XXX not clear what we should return for Unix-domain sockets; let's + * hope the question never arises */ + assert(addr->superfamily != UNIX); if (addr->superfamily == UNRESOLVED) { strncpy(buf, addr->hostname, buflen); buf[buflen-1] = '\0'; @@ -359,9 +361,10 @@ static int sockaddr_is_loopback(struct sockaddr *sa) int sk_address_is_local(SockAddr addr) { - if (addr->superfamily == UNRESOLVED) return 0; /* we don't know; assume not */ + else if (addr->superfamily == UNIX) + return 1; else { #ifndef NO_IPV6 return sockaddr_is_loopback(addr->ais->ai_addr); -- 2.11.0