Re: [PATCH v4] BUG/MINOR: dns: allow 63 char in hostname
On Tue, Jan 28, 2020 at 12:19 AM Miroslav Zagorac wrote: > On 01/28/2020 12:02 AM, Baptiste wrote: > > On Sun, Jan 26, 2020 at 7:53 PM William Dauchy > wrote: > > > >> hostname were limited to 62 char, which is not RFC1035 compliant; > >> - the parsing loop should stop when above max label char > >> - fix len label test where d[i] was wrongly used > >> - simplify the whole function to avoid using two extra char* variable > >> > >> this should fix github issue #387 > >> ... > > > > This patch is "approved". > > Willy, you can apply. > > > > Baptiste > > > > Hello, > > whether in this function is sufficient to check the length of the label > and its contents (uppercase and lowercase letters, numbers and hyphen) > or whether RFC1035 should be followed where it states the following: > > "The labels must follow the rules for ARPANET host names. They must > start with a letter, end with a letter or digit, and have as interior > characters only letters, digits, and hyphen. There are also some > restrictions on the length. Labels must be 63 characters or less." > > -- > Zaga > > What can change the nature of a man? > Thanks Miroslav for the feedback. I am creating a github issue with this content so we can track it. Baptiste
Re: [PATCH v4] BUG/MINOR: dns: allow 63 char in hostname
On Tue, Jan 28, 2020 at 12:02:18AM +0100, Baptiste wrote: > On Sun, Jan 26, 2020 at 7:53 PM William Dauchy wrote: > > > hostname were limited to 62 char, which is not RFC1035 compliant; > > - the parsing loop should stop when above max label char > > - fix len label test where d[i] was wrongly used > > - simplify the whole function to avoid using two extra char* variable > > > > this should fix github issue #387 > > > > Signed-off-by: William Dauchy (...) > This patch is "approved". > Willy, you can apply. OK now applied, thanks! Willy
Re: [PATCH v4] BUG/MINOR: dns: allow 63 char in hostname
On 01/28/2020 12:02 AM, Baptiste wrote: On Sun, Jan 26, 2020 at 7:53 PM William Dauchy wrote: hostname were limited to 62 char, which is not RFC1035 compliant; - the parsing loop should stop when above max label char - fix len label test where d[i] was wrongly used - simplify the whole function to avoid using two extra char* variable this should fix github issue #387 ... This patch is "approved". Willy, you can apply. Baptiste Hello, whether in this function is sufficient to check the length of the label and its contents (uppercase and lowercase letters, numbers and hyphen) or whether RFC1035 should be followed where it states the following: "The labels must follow the rules for ARPANET host names. They must start with a letter, end with a letter or digit, and have as interior characters only letters, digits, and hyphen. There are also some restrictions on the length. Labels must be 63 characters or less." -- Zaga What can change the nature of a man?
Re: [PATCH v4] BUG/MINOR: dns: allow 63 char in hostname
On Sun, Jan 26, 2020 at 7:53 PM William Dauchy wrote: > hostname were limited to 62 char, which is not RFC1035 compliant; > - the parsing loop should stop when above max label char > - fix len label test where d[i] was wrongly used > - simplify the whole function to avoid using two extra char* variable > > this should fix github issue #387 > > Signed-off-by: William Dauchy > --- > src/dns.c | 31 +-- > 1 file changed, 13 insertions(+), 18 deletions(-) > > diff --git a/src/dns.c b/src/dns.c > index eefd8d0dc..28d47d26c 100644 > --- a/src/dns.c > +++ b/src/dns.c > @@ -1470,7 +1470,6 @@ int dns_str_to_dn_label(const char *str, int > str_len, char *dn, int dn_len) > */ > int dns_hostname_validation(const char *string, char **err) > { > - const char *c, *d; > int i; > > if (strlen(string) > DNS_MAX_NAME_SIZE) { > @@ -1479,36 +1478,32 @@ int dns_hostname_validation(const char *string, > char **err) > return 0; > } > > - c = string; > - while (*c) { > - d = c; > - > + while (*string) { > i = 0; > - while (*d != '.' && *d && i <= DNS_MAX_LABEL_SIZE) { > - i++; > - if (!((*d == '-') || (*d == '_') || > - ((*d >= 'a') && (*d <= 'z')) || > - ((*d >= 'A') && (*d <= 'Z')) || > - ((*d >= '0') && (*d <= '9' { > + while (*string && *string != '.' && i < > DNS_MAX_LABEL_SIZE) { > + if (!(*string == '-' || *string == '_' || > + (*string >= 'a' && *string <= 'z') || > + (*string >= 'A' && *string <= 'Z') || > + (*string >= '0' && *string <= '9'))) { > if (err) > *err = DNS_INVALID_CHARACTER; > return 0; > } > - d++; > + i++; > + string++; > } > > - if ((i >= DNS_MAX_LABEL_SIZE) && (d[i] != '.')) { > + if (!(*string)) > + break; > + > + if (*string != '.' && i >= DNS_MAX_LABEL_SIZE) { > if (err) > *err = DNS_LABEL_TOO_LONG; > return 0; > } > > - if (*d == '\0') > - goto out; > - > - c = ++d; > + string++; > } > - out: > return 1; > } > > -- > 2.24.1 > > This patch is "approved". Willy, you can apply. Baptiste
Re: [PATCH v4] BUG/MINOR: dns: allow 63 char in hostname
William, Am 26.01.20 um 19:52 schrieb William Dauchy: > hostname were limited to 62 char, which is not RFC1035 compliant; > - the parsing loop should stop when above max label char > - fix len label test where d[i] was wrongly used > - simplify the whole function to avoid using two extra char* variable > > this should fix github issue #387 > > Signed-off-by: William Dauchy LGTM now Reviewed-by: Tim Duesterhus Best regards Tim Düsterhus
[PATCH v4] BUG/MINOR: dns: allow 63 char in hostname
hostname were limited to 62 char, which is not RFC1035 compliant; - the parsing loop should stop when above max label char - fix len label test where d[i] was wrongly used - simplify the whole function to avoid using two extra char* variable this should fix github issue #387 Signed-off-by: William Dauchy --- src/dns.c | 31 +-- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/dns.c b/src/dns.c index eefd8d0dc..28d47d26c 100644 --- a/src/dns.c +++ b/src/dns.c @@ -1470,7 +1470,6 @@ int dns_str_to_dn_label(const char *str, int str_len, char *dn, int dn_len) */ int dns_hostname_validation(const char *string, char **err) { - const char *c, *d; int i; if (strlen(string) > DNS_MAX_NAME_SIZE) { @@ -1479,36 +1478,32 @@ int dns_hostname_validation(const char *string, char **err) return 0; } - c = string; - while (*c) { - d = c; - + while (*string) { i = 0; - while (*d != '.' && *d && i <= DNS_MAX_LABEL_SIZE) { - i++; - if (!((*d == '-') || (*d == '_') || - ((*d >= 'a') && (*d <= 'z')) || - ((*d >= 'A') && (*d <= 'Z')) || - ((*d >= '0') && (*d <= '9' { + while (*string && *string != '.' && i < DNS_MAX_LABEL_SIZE) { + if (!(*string == '-' || *string == '_' || + (*string >= 'a' && *string <= 'z') || + (*string >= 'A' && *string <= 'Z') || + (*string >= '0' && *string <= '9'))) { if (err) *err = DNS_INVALID_CHARACTER; return 0; } - d++; + i++; + string++; } - if ((i >= DNS_MAX_LABEL_SIZE) && (d[i] != '.')) { + if (!(*string)) + break; + + if (*string != '.' && i >= DNS_MAX_LABEL_SIZE) { if (err) *err = DNS_LABEL_TOO_LONG; return 0; } - if (*d == '\0') - goto out; - - c = ++d; + string++; } - out: return 1; } -- 2.24.1