hostname were limited to 62 char, which is not RFC1035 compliant; - the loop should stop when above max char - fix resulting test where d[i] was wrongly used (also simplify brackets for readability)
this should github issue #387 Signed-off-by: William Dauchy <[email protected]> --- src/dns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dns.c b/src/dns.c index eefd8d0dc..dccd0498c 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1484,7 +1484,7 @@ int dns_hostname_validation(const char *string, char **err) d = c; i = 0; - while (*d != '.' && *d && i <= DNS_MAX_LABEL_SIZE) { + while (*d != '.' && *d && i < DNS_MAX_LABEL_SIZE) { i++; if (!((*d == '-') || (*d == '_') || ((*d >= 'a') && (*d <= 'z')) || @@ -1497,7 +1497,7 @@ int dns_hostname_validation(const char *string, char **err) d++; } - if ((i >= DNS_MAX_LABEL_SIZE) && (d[i] != '.')) { + if (i >= DNS_MAX_LABEL_SIZE && *d != '.') { if (err) *err = DNS_LABEL_TOO_LONG; return 0; -- 2.24.1

