MINOR: resolvers: fix the resolv_dn_label_to_str() API about trailing zero
authorWilly Tarreau <w@1wt.eu>
Thu, 14 Oct 2021 06:05:25 +0000 (08:05 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 3 Nov 2021 10:20:39 +0000 (11:20 +0100)
commita840e11c0cac02706f55e2ab05b123def2d4e40e
tree92e530582e0b81cd131719c4b029793ac3385c7a
parent03fd1759f0c326ffaf2609e457039a9ec37d5be2
MINOR: resolvers: fix the resolv_dn_label_to_str() API about trailing zero

This function suffers from the same API issue as its sibling that does the
opposite direction, it demands that the input string is zero-terminated
*and* that its length *including* the trailing zero is passed on input,
forcing callers to pass length + 1, and itself to use that length - 1
everywhere internally.

This patch addressess this. There is a single caller, which is the
location of the previous bug, so it should probably be backported at
least to keep the code consistent across versions. Note that the
function is called dns_dn_label_to_str() in 2.3 and earlier.

(cherry picked from commit 875ee704dd76b12e5db9ad5c9ae5f2a23b4a4a86)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit ca0170bc83c9c5cd067eaf00283df3a2ae36eb5b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
src/dns.c