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>
Tue, 27 Jul 2021 06:38:22 +0000 (08:38 +0200)
commit8f19baf272477c1f2d5c294ad7cde83d6ff213be
treeda72804201564712ac33995f1e497462dd1afd18
parent97e8d84ffd52eaa460c5f6f3baec805cbc5f888b
BUG/MINOR: resolvers: Use a null-terminated string to lookup in servers tree

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.

(cherry picked from commit 1f923391d1841435de7891682f585c040faef2bc)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit c20d64256cc3c02a012709ce3bb398356fff97ad)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/dns.c