1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-08 07:29:03 +00:00

Fix ncat -lU on OS X crashing in getnameinfo. Fixes #193. Closes #192

This commit is contained in:
dmiller
2015-10-28 17:40:25 +00:00
parent 1d57f25436
commit 46947d1183
2 changed files with 19 additions and 0 deletions

View File

@@ -1,5 +1,10 @@
# Nmap Changelog ($Id$); -*-text-*-
o [Ncat] [GH#193] Fix Ncat listen mode over Unix sockets (named pipes) on OS X.
This was crashing with the error:
Ncat: getnameinfo failed: Undefined error: 0 QUITTING.
Fixed by forcing the name to "localhost" [Michael Wallner]
o [NSE] Added knx-gateway-discover and knx-gateway-info scripts for gathering
information from multicast and unicast KNX gateways, which connect home
automation systems to IP networks. [Niklaus Schiess, Dominik Schneider]

View File

@@ -569,6 +569,13 @@ void setup_environment(struct fdinfo *info)
if (getpeername(info->fd, &su.sockaddr, &alen) != 0) {
bye("getpeername failed: %s", socket_strerror(socket_errno()));
}
#ifdef HAVE_SYS_UN_H
if (su.sockaddr.sa_family == AF_UNIX) {
/* say localhost to keep it backwards compatible */
setenv_portable("NCAT_REMOTE_ADDR", "localhost");
setenv_portable("NCAT_REMOTE_PORT", "");
} else
#endif
if (getnameinfo((struct sockaddr *)&su, alen, ip, sizeof(ip),
port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) == 0) {
setenv_portable("NCAT_REMOTE_ADDR", ip);
@@ -580,6 +587,13 @@ void setup_environment(struct fdinfo *info)
if (getsockname(info->fd, (struct sockaddr *)&su, &alen) < 0) {
bye("getsockname failed: %s", socket_strerror(socket_errno()));
}
#ifdef HAVE_SYS_UN_H
if (su.sockaddr.sa_family == AF_UNIX) {
/* say localhost to keep it backwards compatible, else su.un.sun_path */
setenv_portable("NCAT_LOCAL_ADDR", "localhost");
setenv_portable("NCAT_LOCAL_PORT", "");
} else
#endif
if (getnameinfo((struct sockaddr *)&su, alen, ip, sizeof(ip),
port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV) == 0) {
setenv_portable("NCAT_LOCAL_ADDR", ip);