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

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