>
>
>> Here is a new patch version which takes into an account Baptiste remarks.
>
> Thank you again Baptiste.
>
>
Hi Fred,

I gave a try to your code today and found a segfault at the next DNS
request following the fqdn change.
I attached a patch to this email to fix it, simply merge it into yours.

Note that my fix is temporary, since I'm reorganizing the DNS structures.
The ugly foreach loop will disapear once I'll get my patches merged.

Baptiste
From d44a8bfd8a1f0e49e53a71b0b69274579477fe76 Mon Sep 17 00:00:00 2001
From: Baptiste Assmann <bassm...@brocade.com>
Date: Tue, 2 May 2017 15:40:37 +0200
Subject: [PATCH 2/2] FIX for fred

---
 src/cfgparse.c |  2 --
 src/server.c   | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/cfgparse.c b/src/cfgparse.c
index d44949a..f167321 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -8492,8 +8492,6 @@ out_uri_auth_compat:
 					newsrv->id, newsrv->resolvers_id);
 					cfgerr++;
 				} else {
-					free(newsrv->resolvers_id);
-					newsrv->resolvers_id = NULL;
 					if (newsrv->resolution)
 						newsrv->resolution->resolvers = curr_resolvers;
 				}
diff --git a/src/server.c b/src/server.c
index 536ab6b..85da083 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1690,6 +1690,23 @@ static int srv_alloc_dns_resolution(struct server *srv, const char *hostname)
 	/* a first resolution has been done by the configuration parser */
 	srv->resolution->last_resolution = 0;
 
+	if (srv->resolvers_id) {
+		struct dns_resolvers *curr_resolvers;
+		int found = 0;
+
+		list_for_each_entry(curr_resolvers, &dns_resolvers, list) {
+			if (!strcmp(curr_resolvers->id, srv->resolvers_id)) {
+				found = 1;
+				break;
+			}
+		}
+		if (!found)
+			goto err;
+		srv->resolution->resolvers = curr_resolvers;
+	}
+	else
+		goto err;
+
 	return 0;
 
  err:
-- 
2.7.4

Reply via email to