9
9
extern " C" int LLVMFuzzerTestOneInput (const uint8_t *data, size_t size) {
10
10
FuzzedDataProvider fdp (data, size);
11
11
std::string source = fdp.ConsumeRandomLengthString (256 );
12
- std::string base_source = fdp.ConsumeRandomLengthString (256 );
12
+
13
+ // volatile forces the compiler to store the results without undue
14
+ // optimizations
15
+ volatile size_t length = 0 ;
16
+
17
+ auto parse_url = ada::parse<ada::url>(source);
18
+ auto parse_url_aggregator = ada::parse<ada::url_aggregator>(source);
19
+
20
+ if (parse_url) {
21
+ length += parse_url->get_href ().size ();
22
+ }
23
+
24
+ if (parse_url_aggregator) {
25
+ length += parse_url_aggregator->get_href ().size ();
26
+ }
13
27
14
28
/* *
15
29
* ada::parse<ada::url>
16
30
*/
17
- auto out_url = ada::parse<ada::url>(source );
31
+ auto out_url = ada::parse<ada::url>(" https://www.ada-url.com " );
18
32
19
33
if (out_url) {
20
- std::string input = fdp.ConsumeRandomLengthString (256 );
21
- out_url->set_protocol (input);
22
- out_url->set_username (input);
23
- out_url->set_password (input);
24
- out_url->set_hostname (input);
25
- out_url->set_host (input);
26
- out_url->set_pathname (input);
27
- out_url->set_search (input);
28
- out_url->set_hash (input);
29
- out_url->set_port (input);
30
-
31
- // volatile forces the compiler to store the results without undue
32
- // optimizations
33
- volatile size_t length = 0 ;
34
+ out_url->set_protocol (source);
35
+ out_url->set_username (source);
36
+ out_url->set_password (source);
37
+ out_url->set_hostname (source);
38
+ out_url->set_host (source);
39
+ out_url->set_pathname (source);
40
+ out_url->set_search (source);
41
+ out_url->set_hash (source);
42
+ out_url->set_port (source);
34
43
35
44
// getters
36
45
length += out_url->get_protocol ().size ();
@@ -48,23 +57,19 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
48
57
/* *
49
58
* ada::parse<ada::url_aggregator>
50
59
*/
51
- auto out_aggregator = ada::parse<ada::url_aggregator>(source);
60
+ auto out_aggregator =
61
+ ada::parse<ada::url_aggregator>(" https://www.ada-url.com" );
52
62
53
63
if (out_aggregator) {
54
- std::string input = fdp.ConsumeRandomLengthString (256 );
55
- out_aggregator->set_protocol (input);
56
- out_aggregator->set_username (input);
57
- out_aggregator->set_password (input);
58
- out_aggregator->set_hostname (input);
59
- out_aggregator->set_host (input);
60
- out_aggregator->set_pathname (input);
61
- out_aggregator->set_search (input);
62
- out_aggregator->set_hash (input);
63
- out_aggregator->set_port (input);
64
-
65
- // volatile forces the compiler to store the results without undue
66
- // optimizations
67
- volatile size_t length = 0 ;
64
+ out_aggregator->set_protocol (source);
65
+ out_aggregator->set_username (source);
66
+ out_aggregator->set_password (source);
67
+ out_aggregator->set_hostname (source);
68
+ out_aggregator->set_host (source);
69
+ out_aggregator->set_pathname (source);
70
+ out_aggregator->set_search (source);
71
+ out_aggregator->set_hash (source);
72
+ out_aggregator->set_port (source);
68
73
69
74
// getters
70
75
length += out_aggregator->get_protocol ().size ();
0 commit comments