From: Willy Tarreau Date: Fri, 15 Oct 2021 06:09:25 +0000 (+0200) Subject: BUG/MEDIUM: resolvers: fix truncated TLD consecutive to the API fix X-Git-Tag: v2.5-dev10~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7b232f132dc9a0a6ee6fa3fabfa6e50196af9240;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: resolvers: fix truncated TLD consecutive to the API fix A bug was introduced by commit previous bf9498a31 ("MINOR: resolvers: fix the resolv_str_to_dn_label() API about trailing zero") as the code is particularly contrived and hard to test. The output writes the last char at [i+1] so the trailing zero and return value must be at i+1. This will have to be backported where the patch above is backported since it was needed for a fix. --- diff --git a/src/resolvers.c b/src/resolvers.c index 8caadfe679..9586f3e47b 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -1686,8 +1686,8 @@ int resolv_str_to_dn_label(const char *str, int str_len, char *dn, int dn_len) dn[i+1] = str[i]; } dn[offset] = i - offset; - dn[i] = '\0'; - return i; + dn[i+1] = '\0'; + return i+1; } /* Validates host name: