From 7f2d67a060b41c9ecbb764bd3552ff58a1199efb Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Wed, 28 Nov 2012 16:42:26 +0100 Subject: [PATCH] If source DGRAM UNIX socket exist Ncat should exit When Ncat is connecting to the server using DATAGRAM UNIX socket and source socket exists, Ncat should EXIT. nsock_connect in Nsock should return "-1" if bind() fials when using UNIX sockets. --- nsock/src/nsock_connect.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/nsock/src/nsock_connect.c b/nsock/src/nsock_connect.c index a2f4fcc..9b09a0a 100644 --- a/nsock/src/nsock_connect.c +++ b/nsock/src/nsock_connect.c @@ -84,17 +84,16 @@ static int nsock_make_socket(mspool *ms, msiod *iod, int family, int type, int p setsockopt(iod->sd, SOL_SOCKET, SO_REUSEADDR, (const char *)&one, sizeof(one)); if (bind(iod->sd, (struct sockaddr *)&iod->local, (int) iod->locallen) == -1) { - if (ms->tracelevel > 0) { - const char *addrstr = NULL; #if HAVE_SYS_UN_H - if (iod->local.ss_family == AF_UNIX) - addrstr = get_unixsock_path(&iod->local); - else -#endif - addrstr = inet_ntop_ez(&iod->local, iod->locallen); - - nsock_trace(ms, "Bind to %s failed (IOD #%li)", addrstr, iod->id); + if (iod->local.ss_family == AF_UNIX) { + nsock_trace(ms, "Bind to %s failed (IOD #%li)", + get_unixsock_path(&iod->local), iod->id); + return -1; } +#endif + if (ms->tracelevel > 0) + nsock_trace(ms, "Bind to %s failed (IOD #%li)", + inet_ntop_ez(&iod->local, iod->locallen), iod->id); } } if (iod->ipoptslen && family == AF_INET) { -- 1.7.11.7