Nmap Development mailing list archives
Re: [BUG] add_dns_server() adds bogus IPv4 nameserver address
From: jah <jah () zadkiel plus com>
Date: Wed, 13 Jan 2010 23:19:17 +0000
It wasn't after all, getaddrinfo() that was the problem. After a lot of head scratching, I had a look at my nmap-exp branch where I began work (a long time ago) on ipv6 support for mass_dns. I found that the current code in get_dns_servers() uses inet_ntop() to convert a sockaddr_storage to a string, whereas in my exp branch I'd used inet_socktop(). inet_socktop() works like a charm. I'm not exactly sure what's wrong with using inet_ntop() (or whether it's just called incorrectly in this case), but is there any reason not to use inet_socktop()? If not, I'll check in the attached. Regards, jah
--- nmap_dns.cc.orig 2010-01-13 23:16:26.390625000 +0000 +++ nmap_dns.cc 2010-01-13 23:04:00.812500000 +0000 @@ -1345,7 +1345,6 @@ // Returns a list of known DNS servers std::list<std::string> get_dns_servers() { init_servs(); - char addrStr[INET6_ADDRSTRLEN]; // If the user said --system-dns (!o.mass_dns), we should never return a list // of servers. @@ -1354,8 +1353,7 @@ std::list<dns_server *>::iterator servI; std::list<std::string> serverList; for(servI = servs.begin(); servI != servs.end(); servI++) { - inet_ntop((*servI)->addr.ss_family, (&(*servI)->addr),addrStr, sizeof(addrStr)); - serverList.push_back(addrStr); + serverList.push_back(inet_socktop((struct sockaddr_storage *) &(*servI)->addr)); } return serverList; }
_______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://seclists.org/nmap-dev/
Current thread:
- [BUG] add_dns_server() adds bogus IPv4 nameserver address jah (Jan 13)
- Re: [BUG] add_dns_server() adds bogus IPv4 nameserver address jah (Jan 13)
- Re: [BUG] add_dns_server() adds bogus IPv4 nameserver address David Fifield (Jan 13)
- Re: [BUG] add_dns_server() adds bogus IPv4 nameserver address jah (Jan 13)