diff --git a/CHANGELOG b/CHANGELOG index 82417fc90..35b30d491 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ #Nmap Changelog ($Id$); -*-text-*- +o Fixed an issue with the parallel forward DNS resolver: it had not been + consulting /etc/hosts, nor did it correctly handle the 'localhost' name. + Nmap 7.96 [2025-05-01] o Upgraded included libraries: OpenSSL 3.0.16, Lua 5.4.7, libssh2 1.11.1, diff --git a/nmap_dns.cc b/nmap_dns.cc index e3021d0bf..0cfd2a9cc 100644 --- a/nmap_dns.cc +++ b/nmap_dns.cc @@ -1088,6 +1088,17 @@ static void parse_etchosts(const char *fname) { sockaddr_storage ia; size_t ialen; + // First, load localhost names + line = "localhost"; + if (0 == resolve_numeric("::1", 0, &ia, &ialen, AF_INET6)) { + host_cache.add(ia, line); + etchosts[NameRecord(line, DNS::AAAA)] = ia; + } + if (0 == resolve_numeric("127.0.0.1", 0, &ia, &ialen, AF_INET)) { + host_cache.add(ia, line); + etchosts[NameRecord(line, DNS::A)] = ia; + } + if (ifs.fail()) return; // silently is OK while (std::getline(ifs, line)) {