]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: resolvers: Use a null-terminated string to lookup in servers tree
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 22 Jul 2021 12:29:26 +0000 (14:29 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 22 Jul 2021 13:03:25 +0000 (15:03 +0200)
When we evaluate a DNS response item, it may be necessary to look for a
server with a hostname matching the item target into the named servers
tree. To do so, the item target is transformed to a lowercase string. It
must be a null-terminated string. Thus we must explicitly set the trailing
'\0' character.

For a specific resolution, the named servers tree contains all servers using
this resolution with a hostname loaded from a state file. Because of this
bug, same entry may be duplicated because we are unable to find the right
server, assigning this way the item to a free server slot.

This patch should fix the issue #1333. It must be backported as far as 2.2.

src/resolvers.c

index 0a4ea3528b5e1e71fedf7dd75f8cb582f2edbfb9..1704d7227a00a2e9095784e332d1411e2b26067c 100644 (file)
@@ -694,6 +694,7 @@ static void resolv_check_response(struct resolv_resolution *res)
                                /* convert the key to lookup in lower case */
                                for (i = 0 ; item->target[i] ; i++)
                                        target[i] = tolower(item->target[i]);
+                               target[i] = 0;
 
                                node = ebis_lookup(&srvrq->named_servers, target);
                                if (node) {