Blame SOURCES/dnsmasq-2.79-server-domain-fixup.patch

d4892e
From b027daaa8ef168122a712e5e4ec71642964d8f4d Mon Sep 17 00:00:00 2001
d4892e
From: rpm-build <rpm-build>
d4892e
Date: Mon, 22 Aug 2022 21:59:42 +0200
d4892e
Subject: [PATCH] Ensure also server_domains_cleanup is called always
d4892e
d4892e
Fixes issue in patch dnsmasq-2.79-server-domain-rh1919894.patch.
d4892e
d4892e
When /etc/resolv.conf is changed, dnsmasq reloads used servers. But it
d4892e
does not call cleanup of server domains in this case. It might cause
d4892e
serv_domain->last_server to become non-null, but pointing released
d4892e
server. Ensure it is checked before any cleanup_servers() action always
d4892e
and from all other places, like dbus setting.
d4892e
d4892e
Caused unending loop in forward_query function, rhbz#2106361.
d4892e
---
d4892e
 src/network.c | 49 +++++++++++++++++++++++++------------------------
d4892e
 1 file changed, 25 insertions(+), 24 deletions(-)
d4892e
d4892e
diff --git a/src/network.c b/src/network.c
d4892e
index 1fa81ff..cf2f2e2 100644
d4892e
--- a/src/network.c
d4892e
+++ b/src/network.c
d4892e
@@ -1511,10 +1511,35 @@ void mark_servers(int flag)
d4892e
     }
d4892e
 }
d4892e
 
d4892e
+static void server_domains_cleanup(void)
d4892e
+{
d4892e
+  struct server_domain *sd, *tmp, **up;
d4892e
+
d4892e
+  /* unlink and free anything still marked. */
d4892e
+  for (up = &daemon->server_domains, sd=*up; sd; sd = tmp)
d4892e
+    {
d4892e
+      tmp = sd->next;
d4892e
+      if (sd->flags & SERV_MARK)
d4892e
+       {
d4892e
+         *up = sd->next;
d4892e
+         if (sd->domain)
d4892e
+	   free(sd->domain);
d4892e
+	 free(sd);
d4892e
+       }
d4892e
+      else {
d4892e
+        up = &sd->next;
d4892e
+        if (sd->last_server && (sd->last_server->flags & SERV_MARK))
d4892e
+	  sd->last_server = NULL;
d4892e
+      }
d4892e
+    }
d4892e
+}
d4892e
+
d4892e
 void cleanup_servers(void)
d4892e
 {
d4892e
   struct server *serv, *tmp, **up;
d4892e
 
d4892e
+  server_domains_cleanup();
d4892e
+
d4892e
   /* unlink and free anything still marked. */
d4892e
   for (serv = daemon->servers, up = &daemon->servers; serv; serv = tmp) 
d4892e
     {
d4892e
@@ -1537,29 +1562,6 @@ void cleanup_servers(void)
d4892e
 #endif
d4892e
 }
d4892e
 
d4892e
-static void server_domains_cleanup(void)
d4892e
-{
d4892e
-  struct server_domain *sd, *tmp, **up;
d4892e
-
d4892e
-  /* unlink and free anything still marked. */
d4892e
-  for (up = &daemon->server_domains, sd=*up; sd; sd = tmp)
d4892e
-    {
d4892e
-      tmp = sd->next;
d4892e
-      if (sd->flags & SERV_MARK)
d4892e
-       {
d4892e
-         *up = sd->next;
d4892e
-         if (sd->domain)
d4892e
-	   free(sd->domain);
d4892e
-	 free(sd);
d4892e
-       }
d4892e
-      else {
d4892e
-        up = &sd->next;
d4892e
-        if (sd->last_server && (sd->last_server->flags & SERV_MARK))
d4892e
-	  sd->last_server = NULL;
d4892e
-      }
d4892e
-    }
d4892e
-}
d4892e
-
d4892e
 void add_update_server(int flags,
d4892e
 		       union mysockaddr *addr,
d4892e
 		       union mysockaddr *source_addr,
d4892e
@@ -1849,7 +1851,6 @@ void check_servers(void)
d4892e
 	up = &sfd->next;
d4892e
     }
d4892e
   
d4892e
-  server_domains_cleanup();
d4892e
   cleanup_servers();
d4892e
 }
d4892e
 
d4892e
-- 
d4892e
2.37.2
d4892e