Skip to content

Commit 5598049

Browse files
committed
test: improve fuzzer coverage
1 parent d382015 commit 5598049

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

fuzz/parse.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
2525
out_url->set_pathname(input);
2626
out_url->set_search(input);
2727
out_url->set_hash(input);
28+
out_url->set_port(input);
29+
30+
// volatile forces the compiler to store the results without undue
31+
// optimizations
32+
volatile size_t length = 0;
33+
34+
// getters
35+
length += out_url->get_protocol().size();
36+
length += out_url->get_username().size();
37+
length += out_url->get_password().size();
38+
length += out_url->get_hostname().size();
39+
length += out_url->get_host().size();
40+
length += out_url->get_pathname().size();
41+
length += out_url->get_search().size();
42+
length += out_url->get_hash().size();
43+
length += out_url->get_origin().size();
44+
length += out_url->get_port().size();
2845
}
2946

3047
/**
@@ -42,6 +59,23 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
4259
out_aggregator->set_pathname(input);
4360
out_aggregator->set_search(input);
4461
out_aggregator->set_hash(input);
62+
out_aggregator->set_port(input);
63+
64+
// volatile forces the compiler to store the results without undue
65+
// optimizations
66+
volatile size_t length = 0;
67+
68+
// getters
69+
length += out_aggregator->get_protocol().size();
70+
length += out_aggregator->get_username().size();
71+
length += out_aggregator->get_password().size();
72+
length += out_aggregator->get_hostname().size();
73+
length += out_aggregator->get_host().size();
74+
length += out_aggregator->get_pathname().size();
75+
length += out_aggregator->get_search().size();
76+
length += out_aggregator->get_hash().size();
77+
length += out_aggregator->get_origin().size();
78+
length += out_aggregator->get_port().size();
4579
}
4680

4781
/**
@@ -58,5 +92,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
5892
ada::idna::to_ascii(source);
5993
ada::idna::to_unicode(source);
6094

95+
/**
96+
* Node.js specific
97+
*/
98+
ada::href_from_file(source);
99+
61100
return 0;
62101
} // extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {

0 commit comments

Comments
 (0)