summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Kelley <simon@thekelleys.org.uk>2021-10-06 22:31:06 +0100
committerSimon Kelley <simon@thekelleys.org.uk>2021-10-06 22:31:06 +0100
commitd290630d31f4517ab26392d00753d1397f9a4114 (patch)
tree606097cbc0adc753dddfb2461a2469cfb9f232a1
parentd2ad5dc073aaacaf22b117f16106282a73586803 (diff)
downloaddnsmasq-d290630d31f4517ab26392d00753d1397f9a4114.tar.gz
Fix crash after re-reading an empty resolv.conf file.
If dnsmasq re-reads a resolv file, and it's empty, it will retry after a delay. In the meantime, the old servers from the resolv file have been deleted, but the servers_array doesn't get updated, leading to dangling pointers and crashes. Thanks to Brad Jorsch for finding and analysing this bug. This problem was introduced in 2.86.
-rw-r--r--src/dnsmasq.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/dnsmasq.c b/src/dnsmasq.c
index c7fa024..9516680 100644
--- a/src/dnsmasq.c
+++ b/src/dnsmasq.c
@@ -1682,6 +1682,11 @@ static void poll_resolv(int force, int do_reload, time_t now)
}
else
{
+ /* If we're delaying things, we don't call check_servers(), but
+ reload_servers() may have deleted some servers, rendering the server_array
+ invalid, so just rebuild that here. Once reload_servers() succeeds,
+ we call check_servers() above, which calls build_server_array itself. */
+ build_server_array();
latest->mtime = 0;
if (!warned)
{