summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2021-12-24 18:58:35 +0000
committerSimon Kelley <simon@thekelleys.org.uk>2021-12-24 18:58:35 +0000
commitea33a0130366d316f01be4c891e4f5b247f97171 (patch)
tree9d4dbc0a7c449996706e7665a513c45327bc3544
parent18b1d1424e3b5e36589321caf569fdf6fe0b474a (diff)
downloaddnsmasq-ea33a0130366d316f01be4c891e4f5b247f97171.tar.gz
Fix rare "Internal error in cache" messages.
Fix error created in 1ce1c6beae9f683bec54cba4c0d375f85b209b95 Many thanks to Hartmut Birr for finding the bug and bisecting to the guilty commit. The breaking commit creates cache entries which have F_NXDOMAIN set but none of F_IPV4, F_IPV6 or F_SRV. If cache_scan_free() is called to delete such an entry it will fail to do so. If the cache has no free slots and the least-recently-used slot is such an entry, then a new insertion will attempt to make space by calling cache_scan_free(), which will fail when it should be impossible and trigger the internal error.
-rw-r--r--src/cache.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cache.c b/src/cache.c
index f9a874c..246c3f2 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -413,7 +413,7 @@ static struct crec *cache_scan_free(char *name, union all_addr *addr, unsigned s
if ((crecp->flags & F_FORWARD) && hostname_isequal(cache_get_name(crecp), name))
{
/* Don't delete DNSSEC in favour of a CNAME, they can co-exist */
- if ((flags & crecp->flags & (F_IPV4 | F_IPV6 | F_SRV)) ||
+ if ((flags & crecp->flags & (F_IPV4 | F_IPV6 | F_SRV | F_NXDOMAIN)) ||
(((crecp->flags | flags) & F_CNAME) && !(crecp->flags & (F_DNSKEY | F_DS))))
{
if (crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG))