Skip to content

Commit

Permalink
try to fix fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jan 20, 2025
1 parent 7dc872b commit ff880f6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
1 change: 0 additions & 1 deletion fuzz/idna.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FuzzedDataProvider fdp(data, size);
std::string source = fdp.ConsumeRandomLengthString(256);
std::string base_source = fdp.ConsumeRandomLengthString(256);

/**
* ada::idna
Expand Down
53 changes: 26 additions & 27 deletions fuzz/url_pattern.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,36 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FuzzedDataProvider fdp(data, size);
std::string source = fdp.ConsumeRandomLengthString(256);
std::string base_source = fdp.ConsumeRandomLengthString(256);
std::string source = fdp.ConsumeRandomLengthString(100);

// Without base or options
auto result = ada::parse_url_pattern(source, nullptr, nullptr);
auto result = ada::parse_url_pattern(std::string_view(source), nullptr, nullptr);
(void)result;

// Testing with base_url
std::string_view base_source_view(base_source.data(), base_source.length());
auto result_with_base =
ada::parse_url_pattern(source, &base_source_view, nullptr);
(void)result_with_base;

// Testing with base_url and options
ada::url_pattern_options options{.ignore_case = true};
auto result_with_base_and_options =
ada::parse_url_pattern(source, &base_source_view, &options);
(void)result_with_base_and_options;

// Testing with url_pattern_init and base url.
ada::url_pattern_init init{.protocol = source,
.username = source,
.password = source,
.hostname = source,
.port = source,
.pathname = source,
.search = source,
.hash = source};
auto result_with_init =
ada::parse_url_pattern(init, &base_source_view, nullptr);
(void)result_with_init;
// // Testing with base_url
// std::string_view base_source_view(base_source.data(), base_source.length());
// auto result_with_base =
// ada::parse_url_pattern(source, &base_source_view, nullptr);
// (void)result_with_base;
//
// // Testing with base_url and options
// ada::url_pattern_options options{.ignore_case = true};
// auto result_with_base_and_options =
// ada::parse_url_pattern(source, &base_source_view, &options);
// (void)result_with_base_and_options;
//
// // Testing with url_pattern_init and base url.
// ada::url_pattern_init init{.protocol = source,
// .username = source,
// .password = source,
// .hostname = source,
// .port = source,
// .pathname = source,
// .search = source,
// .hash = source};
// auto result_with_init =
// ada::parse_url_pattern(init, &base_source_view, nullptr);
// (void)result_with_init;

return 0;
}
4 changes: 4 additions & 0 deletions fuzz/url_pattern.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[libfuzzer]
dict = url.dict
max_len = 512
rss_limit_mb = 3000

0 comments on commit ff880f6

Please sign in to comment.