diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c index 0289882c8..d745f161b 100644 --- a/ncat/ncat_connect.c +++ b/ncat/ncat_connect.c @@ -560,7 +560,7 @@ int ncat_connect(void) if (srcaddr.storage.ss_family != AF_UNIX) { char *tmp_name = NULL; /* If no source socket was specified, we have to create temporary one. */ - if ((tmp_name = tempnam(NULL, "ncat.")) == NULL) + if ((tmp_name = tempfile(NULL, "ncat.")) == NULL) bye("Failed to create name for temporary DGRAM source Unix domain socket (tempnam)."); srcaddr.un.sun_family = AF_UNIX; diff --git a/nsock/src/nsock_connect.c b/nsock/src/nsock_connect.c index 9fd396ae7..a313bd8a2 100644 --- a/nsock/src/nsock_connect.c +++ b/nsock/src/nsock_connect.c @@ -67,6 +67,7 @@ static int mksock_bind_addr(mspool *ms, msiod *iod) { + const char *path; int rc; int one = 1; @@ -78,13 +79,15 @@ static int mksock_bind_addr(mspool *ms, msiod *iod) { socket_strerror(err), err); } - nsock_log_info(ms, "Binding to %s (IOD #%li)", get_localaddr_string(iod), iod->id); + path = get_localaddr_string(iod); + unlink(path); + nsock_log_info(ms, "Binding to %s (IOD #%li)", path, iod->id); rc = bind(iod->sd, (struct sockaddr *)&iod->local, (int) iod->locallen); if (rc == -1) { int err = socket_errno(); nsock_log_error(ms, "Bind to %s failed (IOD #%li): %s (%d)", - get_localaddr_string(iod), iod->id, + path, iod->id, socket_strerror(err), err); } return 0;