diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-11-11 11:51:08 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-11-11 11:51:08 +0100 |
commit | c0a25aa92b612786f4e45292c4aee1d7d47123f8 (patch) | |
tree | 484996008ac28bfeba4d327994b652c32252c42c /resolv/tst-res_hnok.c | |
parent | 9e0ad3049dbae88d615bfb038e53bf365a39a634 (diff) | |
download | glibc-c0a25aa92b612786f4e45292c4aee1d7d47123f8.tar glibc-c0a25aa92b612786f4e45292c4aee1d7d47123f8.tar.gz glibc-c0a25aa92b612786f4e45292c4aee1d7d47123f8.tar.bz2 glibc-c0a25aa92b612786f4e45292c4aee1d7d47123f8.zip |
resolv: More precise checks in res_hnok, res_dnok [BZ #22409] [BZ #22412]
res_hnok rejected some host names used on the Internet, such as
www-.example.com. res_hnok and res_dnok failed to perform basic syntax
checking on DNS domain names.
Also fix res_mailok, res_ownok.
Diffstat (limited to 'resolv/tst-res_hnok.c')
-rw-r--r-- | resolv/tst-res_hnok.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/resolv/tst-res_hnok.c b/resolv/tst-res_hnok.c index 9c92303821..314477a2ce 100644 --- a/resolv/tst-res_hnok.c +++ b/resolv/tst-res_hnok.c @@ -51,19 +51,31 @@ static const struct test_case tests[] = { { "", allok }, { ".", allok }, + { "..", 0 }, { "www", allnomailok }, + { "www.", allnomailok }, { "example", allnomailok }, { "example.com", allok }, { "www.example.com", allok }, { "www.example.com.", allok }, + { "www-.example.com.", allok }, + { "www.-example.com.", allok }, { "*.example.com", dnok | mailok | ownok }, { "-v", dnok }, { "-v.example.com", mailok | dnok }, { "**.example.com", dnok | mailok }, + { "www.example.com\\", 0 }, { STRING63, allnomailok }, + { STRING63 ".", allnomailok }, + { STRING63 "\\.", 0 }, + { STRING63 "z", 0 }, { STRING63 ".example.com", allok }, { STRING63 "." STRING63 "." STRING63 "." STRING60 "z", allok }, + { STRING63 "." STRING63 "." STRING63 "." STRING60 "z.", allok }, + { STRING63 "." STRING63 "." STRING63 "." STRING60 "zz", 0 }, + { STRING63 "." STRING63 "." STRING63 "." STRING60 "zzz", 0 }, { "hostmaster@mail.example.com", dnok | mailok }, + { "hostmaster\\@mail.example.com", dnok | mailok }, { "with whitespace", 0 }, { "with\twhitespace", 0 }, { "with\nwhitespace", 0 }, @@ -116,6 +128,12 @@ one_char (const char *prefix, const char *accepted, const char *suffix, } } +#define LETTERSDIGITS \ + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" + +#define PRINTABLE \ + "!\"#$%&'()*+,/:;<=>?@[\\]^`{|}~" + static int do_test (void) { @@ -131,20 +149,18 @@ do_test (void) } one_char - ("", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.", - "", "res_hnok", res_hnok); + ("", LETTERSDIGITS "._", "", "res_hnok", res_hnok); one_char ("middle", - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_", + LETTERSDIGITS ".-_\\", /* "middle\\suffix" == "middlesuffix", so good. */ "suffix", "res_hnok", res_hnok); one_char ("middle", - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_" - "!\"#$%&'()*+,/:;<=>?@[\\]^`{|}~", + LETTERSDIGITS ".-_" PRINTABLE, "suffix.example", "res_mailok", res_mailok); one_char ("mailbox.middle", - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_", + LETTERSDIGITS ".-_\\", "suffix.example", "res_mailok", res_mailok); return 0; |