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

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