]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: dns: check for duplicate nameserver id in a resolvers section was missing
authorBaptiste Assmann <bedis9@gmail.com>
Mon, 2 Nov 2015 21:55:49 +0000 (22:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 3 Nov 2015 08:56:29 +0000 (09:56 +0100)
Current resolvers section parsing function is permissive on nameserver
id and two nameservers may have the same id.
It's a shame, since we don't know for example, whose statistics belong
to which nameserver...

From now, configuration with duplicated nameserver id in a resolvers
section are considered as broken and returns a fatal error when parsing.

src/cfgparse.c

index 610e165bab52b8c0629033d7183db3bb17573283..f4bc5033ef00cc55c409876a30edff59c8ddbc34 100644 (file)
@@ -2262,6 +2262,15 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
+               list_for_each_entry(newnameserver, &curr_resolvers->nameserver_list, list) {
+                       /* Error if two resolvers owns the same name */
+                       if (strcmp(newnameserver->id, args[1]) == 0) {
+                               Alert("Parsing [%s:%d]: nameserver '%s' has same name as another nameserver (declared at %s:%d).\n",
+                                       file, linenum, args[1], curr_resolvers->conf.file, curr_resolvers->conf.line);
+                               err_code |= ERR_ALERT | ERR_FATAL;
+                       }
+               }
+
                if ((newnameserver = (struct dns_nameserver *)calloc(1, sizeof(struct dns_nameserver))) == NULL) {
                        Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
                        err_code |= ERR_ALERT | ERR_ABORT;