mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Handle multiple addresses when removing duplicates in host files.
This commit is contained in:
committed by
Simon Kelley
parent
0017dd74d5
commit
936be022d9
13
src/cache.c
13
src/cache.c
@@ -1048,16 +1048,17 @@ struct crec *cache_find_by_addr(struct crec *crecp, union all_addr *addr,
|
|||||||
static void add_hosts_entry(struct crec *cache, union all_addr *addr, int addrlen,
|
static void add_hosts_entry(struct crec *cache, union all_addr *addr, int addrlen,
|
||||||
unsigned int index, struct crec **rhash, int hashsz)
|
unsigned int index, struct crec **rhash, int hashsz)
|
||||||
{
|
{
|
||||||
struct crec *lookup = cache_find_by_name(NULL, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6));
|
|
||||||
int i;
|
int i;
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
struct crec *lookup = NULL;
|
||||||
|
|
||||||
/* Remove duplicates in hosts files. */
|
/* Remove duplicates in hosts files. */
|
||||||
if (lookup && (lookup->flags & F_HOSTS) && memcmp(&lookup->addr, addr, addrlen) == 0)
|
while ((lookup = cache_find_by_name(lookup, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6))))
|
||||||
{
|
if ((lookup->flags & F_HOSTS) && memcmp(&lookup->addr, addr, addrlen) == 0)
|
||||||
free(cache);
|
{
|
||||||
return;
|
free(cache);
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ensure there is only one address -> name mapping (first one trumps)
|
/* Ensure there is only one address -> name mapping (first one trumps)
|
||||||
We do this by steam here, The entries are kept in hash chains, linked
|
We do this by steam here, The entries are kept in hash chains, linked
|
||||||
|
|||||||
Reference in New Issue
Block a user