master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "unitcheck.h"
25#include "curlx/strdup.h"
26#include "vtls/hostcheck.h"
28static CURLcode test_unit1397(const char *arg)
29{
30 UNITTEST_BEGIN_SIMPLE
32/* only these backends define the tested functions */
33#if defined(USE_OPENSSL) || defined(USE_SCHANNEL)
35 struct testcase {
36 const char *host;
37 const char *pattern;
38 bool match;
39 };
41 static const struct testcase tests[] = {
42 { ".hello.com", "*.hello.com", FALSE },
43 { "a.hello.com", "*.hello.com", TRUE },
44 { "", "", FALSE },
45 { "a", "", FALSE },
46 { "", "b", FALSE },
47 { "a", "b", FALSE },
48 { "aa", "bb", FALSE },
49 { "a", "*", FALSE },
50 { "\xff", "\xff", TRUE },
51 { "aa.aa.aa", "aa.aa.bb", FALSE },
52 { "aa.aa.aa", "aa.aa.aa", TRUE },
53 { "aa.aa.aa", "*.aa.bb", FALSE },
54 { "aa.aa.aa", "*.aa.aa", TRUE },
55 { "192.168.0.1", "192.168.0.1", TRUE },
56 { "192.168.0.1", "*.168.0.1", FALSE },
57 { "192.168.0.1", "*.0.1", FALSE },
58 { "h.ello", "*.ello", FALSE },
59 { "h.ello.", "*.ello", FALSE },
60 { "h.ello", "*.ello.", FALSE },
61 { "h.e.llo", "*.e.llo", TRUE },
62 { "h.e.llo", " *.e.llo", FALSE },
63 { " h.e.llo", "*.e.llo", TRUE },
64 { "h.e.llo.", "*.e.llo", TRUE },
65 { "*.e.llo.", "*.e.llo", TRUE },
66 { "************.e.llo.", "*.e.llo", TRUE },
67 { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
68 "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
69 "CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC"
70 "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"
71 "EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"
72 ".e.llo.", "*.e.llo", TRUE },
73 { "\xfe\xfe.e.llo.", "*.e.llo", TRUE },
74 { "h.e.llo.", "*.e.llo.", TRUE },
75 { "h.e.llo", "*.e.llo.", TRUE },
76 { ".h.e.llo", "*.e.llo.", FALSE },
77 { "h.e.llo", "*.*.llo.", FALSE },
78 { "h.e.llo", "h.*.llo", FALSE },
79 { "h.e.llo", "h.e.*", FALSE },
80 { "hello", "*.ello", FALSE },
81 { "hello", "**llo", FALSE },
82 { "bar.foo.example.com", "*.example.com", FALSE },
83 { "foo.example.com", "*.example.com", TRUE },
84 { "baz.example.net", "b*z.example.net", FALSE },
85 { "foobaz.example.net", "*baz.example.net", FALSE },
86 { "xn--l8j.example.local", "x*.example.local", FALSE },
87 { "xn--l8j.example.net", "*.example.net", TRUE },
88 { "xn--l8j.example.net", "*j.example.net", FALSE },
89 { "xn--l8j.example.net", "xn--l8j.example.net", TRUE },
90 { "xn--l8j.example.net", "xn--l8j.*.net", FALSE },
91 { "xl8j.example.net", "*.example.net", TRUE },
92 { "fe80::3285:a9ff:fe46:b619", "*::3285:a9ff:fe46:b619", FALSE },
93 { "fe80::3285:a9ff:fe46:b619", "fe80::3285:a9ff:fe46:b619", TRUE },
94 { NULL, NULL, FALSE }
95 };
97 int i;
98 for(i = 0; tests[i].host; i++) {
99 size_t pattern_len;
100 char *pattern;
101 if(tests[i].match != Curl_cert_hostcheck(tests[i].pattern,
102 strlen(tests[i].pattern),
103 tests[i].host,
104 strlen(tests[i].host))) {
105 curl_mfprintf(stderr,
106 "HOST: %s\n"
107 "PTRN: %s\n"
108 "did %sMATCH\n",
109 tests[i].host,
110 tests[i].pattern,
111 tests[i].match ? "NOT " : "");
112 unitfail++;
113 }
115 /* Curl_cert_hostcheck() should not rely on null-terminators in the
116 * pattern. The underlying TLS library might not make a null-terminated
117 * copy of the pattern. Copy it to a new buffer so ASan and valgrind can
118 * flag invalid accesses. */
119 pattern_len = strlen(tests[i].pattern);
120 pattern = pattern_len ? curlx_memdup(tests[i].pattern, pattern_len) : NULL;
121 abort_unless(pattern_len == 0 || pattern, "Out of memory");
122 if(tests[i].match != Curl_cert_hostcheck(pattern,
123 pattern_len,
124 tests[i].host,
125 strlen(tests[i].host))) {
126 curl_mfprintf(stderr,
127 "HOST: %s\n"
128 "PTRN: %s\n"
129 "did %sMATCH\n",
130 tests[i].host,
131 tests[i].pattern,
132 tests[i].match ? "NOT " : "");
133 unitfail++;
134 }
135 curlx_free(pattern);
136 }
138 /* Embedded NUL bytes in the pattern should not be misinterpreted. */
139 if(Curl_cert_hostcheck("foo\0bar", 7, "foo", 3)) {
140 curl_mfprintf(stderr, "foo\\0bar incorrectly matched foo\n");
141 unitfail++;
142 }
143 if(Curl_cert_hostcheck("foo\0bar", 7, "foo.bar", 7)) {
144 curl_mfprintf(stderr, "foo\\0bar incorrectly matched foo.bar\n");
145 unitfail++;
146 }
147#endif
149 UNITTEST_END_SIMPLE
150}
Diagnostics4 git calls · 203 ms
CallStatusSizeTime0203 ms
discover200152 B2 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2001.7 KiB197 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=197 git.response.bytes=1708 git.response.cache=MISS git.response.duration_ms=197 git.fetch.wants=18a1a4468090ece60ffdeaa370bf9a356fba0647 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=1708 git.pkt.payload.max=1687 git.sideband.band1.bytes=1686 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e1fd9cdd66a9c0
- Request
- 438fd9f0…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format