From 904f655aca38e0ba74d9eb3926de3d9b1cc9fe72 Mon Sep 17 00:00:00 2001 From: david Date: Sat, 7 Nov 2009 02:29:23 +0000 Subject: [PATCH] Keep track of the size of the sockaddr structure we get back when resolving DNS servers. Pass that to nsock_connect_udp instead of using sizeof(sockaddr_storage). Mac OS X return EINVAL if the length is not what's expected for the address family. --- nmap_dns.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nmap_dns.cc b/nmap_dns.cc index 875c127b4..304daecff 100644 --- a/nmap_dns.cc +++ b/nmap_dns.cc @@ -244,6 +244,7 @@ typedef struct host_elem_s host_elem; struct dns_server_s { char *hostname; sockaddr_storage addr; + size_t addr_len; nsock_iod nsd; int connected; int reqs_on_wire; @@ -813,6 +814,7 @@ static void add_dns_server(char *ipaddrs) { tpserv->hostname = strdup(hostname); memcpy(&tpserv->addr, &addr, sizeof(addr)); + tpserv->addr_len = addr_len; servs.push_front(tpserv); @@ -860,7 +862,7 @@ static void connect_dns_servers() { s->capacity = CAPACITY_MIN; s->write_busy = 0; - nsock_connect_udp(dnspool, s->nsd, connect_evt_handler, NULL, (struct sockaddr *) &s->addr, sizeof(s->addr), 53); + nsock_connect_udp(dnspool, s->nsd, connect_evt_handler, NULL, (struct sockaddr *) &s->addr, s->addr_len, 53); nsock_read(dnspool, s->nsd, read_evt_handler, -1, NULL); s->connected = 1; }