-
-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate fuzzers into different files (#655)
- Loading branch information
1 parent
a652cbc
commit 2cea09f
Showing
5 changed files
with
121 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <fuzzer/FuzzedDataProvider.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "ada.cpp" | ||
#include "ada.h" | ||
|
||
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::can_parse | ||
*/ | ||
auto base_source_view = | ||
std::string_view(base_source.data(), base_source.length()); | ||
ada::can_parse(source); | ||
ada::can_parse(source, &base_source_view); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <fuzzer/FuzzedDataProvider.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "ada.cpp" | ||
#include "ada.h" | ||
|
||
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 | ||
*/ | ||
ada::idna::to_ascii(source); | ||
ada::idna::to_unicode(source); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <fuzzer/FuzzedDataProvider.h> | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "ada.cpp" | ||
#include "ada.h" | ||
|
||
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::url_search_params | ||
*/ | ||
|
||
auto base_source_view = | ||
std::string_view(base_source.data(), base_source.length()); | ||
auto initialized = ada::url_search_params(base_source_view); | ||
|
||
auto search_params = ada::url_search_params(); | ||
search_params.append(source, base_source); | ||
search_params.set(source, base_source); | ||
search_params.to_string(); | ||
if (!search_params.has(base_source)) { | ||
search_params.append(base_source, source); | ||
} | ||
search_params.remove(source); | ||
search_params.remove(source, base_source); | ||
if (search_params.has(base_source, source)) { | ||
search_params.remove(base_source); | ||
search_params.remove(base_source, source); | ||
} | ||
|
||
auto keys = search_params.get_keys(); | ||
while (keys.has_next()) { | ||
keys.next(); | ||
} | ||
|
||
auto values = search_params.get_values(); | ||
while (values.has_next()) { | ||
values.next(); | ||
} | ||
|
||
auto entries = search_params.get_entries(); | ||
while (entries.has_next()) { | ||
entries.next(); | ||
} | ||
|
||
return 0; | ||
} |