Skip to content

Commit 6cbfc12

Browse files
authored
increase fuzzing coverage (#677)
1 parent b8481bd commit 6cbfc12

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

fuzz/parse.cc

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
152152
length += out_url->get_origin().size();
153153
length += out_url->get_port().size();
154154

155-
out_url->to_string();
155+
length += out_url->to_string().size();
156156
}
157157

158158
/**
@@ -184,9 +184,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
184184
length += out_aggregator->get_origin().size();
185185
length += out_aggregator->get_port().size();
186186

187-
out_aggregator->to_string();
188-
out_aggregator->to_diagram();
189-
out_aggregator->validate();
187+
volatile bool is_output_valid = false;
188+
length += out_aggregator->to_string().size();
189+
is_output_valid = out_aggregator->validate();
190+
191+
// Printing due to dead-code elimination
192+
printf("diagram %s\n", out_aggregator->to_diagram().c_str());
190193

191194
// clear methods
192195
out_aggregator->clear_port();
@@ -197,7 +200,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
197200
/**
198201
* Node.js specific
199202
*/
200-
ada::href_from_file(source);
203+
length += ada::href_from_file(source).size();
204+
205+
/**
206+
* Others
207+
*/
208+
bool is_valid = ada::checkers::verify_dns_length(source);
209+
210+
// Only used for avoiding dead-code elimination
211+
if (is_valid) {
212+
printf("dns length is valid\n");
213+
}
214+
215+
// Only used for avoiding dead-code elimination
216+
printf("length of url is %d\n", length);
201217

202218
return 0;
203219
} // extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

fuzz/url.dict

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,26 @@
1-
"ftp://"
2-
"file://"
3-
"http://"
4-
"https://"
5-
"ws://"
6-
"wss://"
1+
# Protocols
2+
"ftp:"
3+
"file:"
4+
"http:"
5+
"https:"
6+
"ws:"
7+
"wss:"
8+
9+
# Suffixes
710
".com"
11+
12+
# Full URLs
13+
"https://www.ada-url.com"
14+
15+
# Encoded characters
16+
"%2f"
17+
"%40"
18+
"%26"
19+
20+
# Misc
21+
"://"
22+
"//"
23+
"\\"
24+
"../"
25+
";type=a"
26+
"xn--"

0 commit comments

Comments
 (0)