1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-25 08:59:01 +00:00

Fix NSE trace printing of IPv6 addresses. The code was using a plain

sockaddr instead of sockaddr_storage so it got only a fraction of the
address and the inet_ntop function would look outside of the structure
into adjacent memory. A scan of localhost would look like this:

NSE: TCP ::a00:0:600:0:1234 > ::a00:4d2:0:0:25 | CONNECT

Here, for example, that 4d2 is the port number 1234 from the other
structure. Now it prints correctly:

NSE: TCP ::1:1234 > ::1:25 | CONNECT
This commit is contained in:
david
2009-10-11 21:51:51 +00:00
parent cca80f0304
commit dd6eb63b36

View File

@@ -813,9 +813,9 @@ void l_nsock_trace(nsock_iod nsiod, const char *message, int direction)
int protocol;
int af;
struct sockaddr local;
struct sockaddr_storage local;
struct sockaddr remote;
struct sockaddr_storage remote;
if (!nsi_is_pcap(nsiod))
{
@@ -823,7 +823,7 @@ void l_nsock_trace(nsock_iod nsiod, const char *message, int direction)
char *ipstring_remote = (char *) safe_malloc(sizeof(char) * INET6_ADDRSTRLEN);
status = nsi_getlastcommunicationinfo(nsiod, &protocol, &af,
&local, &remote, sizeof(sockaddr));
(sockaddr *) &local, (sockaddr *) &remote, sizeof(sockaddr_storage));
log_write(LOG_STDOUT, "%s: %s %s:%d %s %s:%d | %s\n",
SCRIPT_ENGINE,
IPPROTO2STR_UC(protocol),