mirror of
https://github.com/curl/curl.git
synced 2026-08-25 09:53:32 +03:00
hostcheck: pass in pattern length too, to avoid a strlen call
Removes one strlen() call per SAN name in a cert-check. Closes #8418
This commit is contained in:
parent
9bc3cebc92
commit
d15692ebba
6 changed files with 57 additions and 50 deletions
|
|
@ -40,35 +40,39 @@ UNITTEST_START
|
|||
|
||||
/* here you start doing things and checking that the results are good */
|
||||
|
||||
fail_unless(Curl_cert_hostcheck("www.example.com", "www.example.com"),
|
||||
"good 1");
|
||||
fail_unless(Curl_cert_hostcheck("*.example.com", "www.example.com"),
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("www.example.com"),
|
||||
"www.example.com"), "good 1");
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("*.example.com"), "www.example.com"),
|
||||
"good 2");
|
||||
fail_unless(Curl_cert_hostcheck("xxx*.example.com", "xxxwww.example.com"),
|
||||
"good 3");
|
||||
fail_unless(Curl_cert_hostcheck("f*.example.com", "foo.example.com"),
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("xxx*.example.com"),
|
||||
"xxxwww.example.com"), "good 3");
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("f*.example.com"), "foo.example.com"),
|
||||
"good 4");
|
||||
fail_unless(Curl_cert_hostcheck("192.168.0.0", "192.168.0.0"),
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("192.168.0.0"), "192.168.0.0"),
|
||||
"good 5");
|
||||
|
||||
fail_if(Curl_cert_hostcheck("xxx.example.com", "www.example.com"), "bad 1");
|
||||
fail_if(Curl_cert_hostcheck("*", "www.example.com"), "bad 2");
|
||||
fail_if(Curl_cert_hostcheck("*.*.com", "www.example.com"), "bad 3");
|
||||
fail_if(Curl_cert_hostcheck("*.example.com", "baa.foo.example.com"), "bad 4");
|
||||
fail_if(Curl_cert_hostcheck("f*.example.com", "baa.example.com"), "bad 5");
|
||||
fail_if(Curl_cert_hostcheck("*.com", "example.com"), "bad 6");
|
||||
fail_if(Curl_cert_hostcheck("*fail.com", "example.com"), "bad 7");
|
||||
fail_if(Curl_cert_hostcheck("*.example.", "www.example."), "bad 8");
|
||||
fail_if(Curl_cert_hostcheck("*.example.", "www.example"), "bad 9");
|
||||
fail_if(Curl_cert_hostcheck("", "www"), "bad 10");
|
||||
fail_if(Curl_cert_hostcheck("*", "www"), "bad 11");
|
||||
fail_if(Curl_cert_hostcheck("*.168.0.0", "192.168.0.0"), "bad 12");
|
||||
fail_if(Curl_cert_hostcheck("www.example.com", "192.168.0.0"), "bad 13");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("xxx.example.com"),
|
||||
"www.example.com"), "bad 1");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*"), "www.example.com"), "bad 2");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.*.com"), "www.example.com"), "bad 3");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.example.com"),
|
||||
"baa.foo.example.com"), "bad 4");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("f*.example.com"),
|
||||
"baa.example.com"), "bad 5");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.com"), "example.com"), "bad 6");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*fail.com"), "example.com"), "bad 7");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.example."), "www.example."), "bad 8");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.example."), "www.example"), "bad 9");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST(""), "www"), "bad 10");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*"), "www"), "bad 11");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*.168.0.0"), "192.168.0.0"), "bad 12");
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("www.example.com"),
|
||||
"192.168.0.0"), "bad 13");
|
||||
|
||||
#ifdef ENABLE_IPV6
|
||||
fail_if(Curl_cert_hostcheck("*::3285:a9ff:fe46:b619",
|
||||
fail_if(Curl_cert_hostcheck(STRCONST("*::3285:a9ff:fe46:b619"),
|
||||
"fe80::3285:a9ff:fe46:b619"), "bad 14");
|
||||
fail_unless(Curl_cert_hostcheck("fe80::3285:a9ff:fe46:b619",
|
||||
fail_unless(Curl_cert_hostcheck(STRCONST("fe80::3285:a9ff:fe46:b619"),
|
||||
"fe80::3285:a9ff:fe46:b619"), "good 6");
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue