mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Fixed a bug in nmap_dns.cc where the endian of the platform that nmap ran on
might negitivly effect how efficiently nmap stores cache values in a hash table. Now ntohl is called to correctly reorder the values on little endian platforms before the hash calculation is preformed.
This commit is contained in:
parent
0708d3144d
commit
47e4b7aee5
1 changed files with 5 additions and 3 deletions
|
|
@ -240,6 +240,8 @@ static int read_timeouts[][4] = {
|
|||
// Size of hash table used to hold the hosts from /etc/hosts
|
||||
#define HASH_TABLE_SIZE 256
|
||||
|
||||
// Hash macro for etchosts
|
||||
#define IP_HASH(x) (ntohl(x)%HASH_TABLE_SIZE)
|
||||
|
||||
|
||||
//------------------- Internal Structures ---------------------
|
||||
|
|
@ -1047,7 +1049,7 @@ static void addto_etchosts(u32 ip, const char *hname) {
|
|||
he->name = strdup(hname);
|
||||
he->addr = ip;
|
||||
he->cache_hits = 0;
|
||||
etchosts[ip % HASH_TABLE_SIZE].push_back(he);
|
||||
etchosts[IP_HASH(ip)].push_back(he);
|
||||
total_size++;
|
||||
}
|
||||
|
||||
|
|
@ -1056,8 +1058,8 @@ static void addto_etchosts(u32 ip, const char *hname) {
|
|||
static char *lookup_etchosts(u32 ip) {
|
||||
std::list<host_elem *>::iterator hostI;
|
||||
host_elem *tpelem;
|
||||
|
||||
for(hostI = etchosts[ip % HASH_TABLE_SIZE].begin(); hostI != etchosts[ip % HASH_TABLE_SIZE].end(); hostI++) {
|
||||
int localIP_Hash = IP_HASH(ip);
|
||||
for(hostI = etchosts[localIP_Hash].begin(); hostI != etchosts[localIP_Hash].end(); hostI++) {
|
||||
tpelem = *hostI;
|
||||
if (tpelem->addr == ip) {
|
||||
if(tpelem->cache_hits < UCHAR_MAX)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue