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

Correctly print VM socket address. Closes #1868

This commit is contained in:
dmiller
2019-12-30 00:53:23 +00:00
parent 254d155634
commit 866dc375e4
3 changed files with 29 additions and 0 deletions

View File

@@ -1,5 +1,8 @@
#Nmap Changelog ($Id$); -*-text-*-
o [Ncat][GH#1868] Fix a fatal error when connecting to a Linux VM socket with
verbose output enabled. [Stefano Garzarella]
o [NSE][GH#1723] Fixed a crash on Windows when processing a GZIP-encoded HTTP
body. [Daniel Miller]

View File

@@ -326,6 +326,11 @@ static void connect_report(nsock_iod nsi)
if (peer.sockaddr.sa_family == AF_UNIX)
loguser("Connected to %s.\n", peer.un.sun_path);
else
#endif
#ifdef HAVE_LINUX_VM_SOCKETS_H
if (peer.sockaddr.sa_family == AF_VSOCK)
loguser("Connection to %u.\n", peer.vm.svm_cid);
else
#endif
loguser("Connected to %s:%d.\n", inet_socktop(&peer),
nsock_iod_get_peerport(nsi));
@@ -335,6 +340,11 @@ static void connect_report(nsock_iod nsi)
if (peer.sockaddr.sa_family == AF_UNIX)
loguser("Connected to %s.\n", peer.un.sun_path);
else
#endif
#ifdef HAVE_LINUX_VM_SOCKETS_H
if (peer.sockaddr.sa_family == AF_VSOCK)
loguser("Connection to %u.\n", peer.vm.svm_cid);
else
#endif
loguser("Connected to %s:%d.\n", inet_socktop(&peer),
nsock_iod_get_peerport(nsi));

View File

@@ -479,6 +479,11 @@ static void handle_connection(int socket_accept)
if (remoteaddr.sockaddr.sa_family == AF_UNIX)
loguser("Connection from a client on Unix domain socket.\n");
else
#endif
#ifdef HAVE_LINUX_VM_SOCKETS_H
if (remoteaddr.sockaddr.sa_family == AF_VSOCK)
loguser("Connection from a client on vsock socket.\n");
else
#endif
if (o.chat)
loguser("Connection from %s on file descriptor %d.\n", inet_socktop(&remoteaddr), s.fd);
@@ -500,6 +505,12 @@ static void handle_connection(int socket_accept)
if (remoteaddr.sockaddr.sa_family == AF_UNIX)
loguser("Connection from %s.\n", remoteaddr.un.sun_path);
else
#endif
#ifdef HAVE_LINUX_VM_SOCKETS_H
if (remoteaddr.sockaddr.sa_family == AF_VSOCK)
loguser("Connection from %u:%u.\n",
remoteaddr.vm.svm_cid, remoteaddr.vm.svm_port);
else
#endif
loguser("Connection from %s:%hu.\n", inet_socktop(&remoteaddr), inet_port(&remoteaddr));
}
@@ -883,6 +894,11 @@ static int ncat_listen_dgram(int proto)
if (remotess.sockaddr.sa_family == AF_UNIX)
loguser("Connection from %s.\n", remotess.un.sun_path);
else
#endif
#ifdef HAVE_LINUX_VM_SOCKETS_H
if (remotess.sockaddr.sa_family == AF_VSOCK)
loguser("Connection from %u.\n", remotess.vm.svm_cid);
else
#endif
loguser("Connection from %s.\n", inet_socktop(&remotess));
}