aboutsummaryrefslogtreecommitdiff
path: root/tests/fuzz/parse_url.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fuzz/parse_url.cpp')
-rw-r--r--tests/fuzz/parse_url.cpp48
1 files changed, 6 insertions, 42 deletions
diff --git a/tests/fuzz/parse_url.cpp b/tests/fuzz/parse_url.cpp
index 3db78f9d9..41f4319a6 100644
--- a/tests/fuzz/parse_url.cpp
+++ b/tests/fuzz/parse_url.cpp
@@ -31,46 +31,10 @@
#include "net/net_parse_helpers.h"
#include "fuzzer.h"
-class ParseURLFuzzer: public Fuzzer
-{
-public:
- ParseURLFuzzer() {}
- virtual int init();
- virtual int run(const std::string &filename);
-};
-
-int ParseURLFuzzer::init()
-{
- return 0;
-}
-
-int ParseURLFuzzer::run(const std::string &filename)
-{
- std::string s;
-
- if (!epee::file_io_utils::load_file_to_string(filename, s))
- {
- std::cout << "Error: failed to load file " << filename << std::endl;
- return 1;
- }
- try
- {
- epee::net_utils::http::url_content url;
- epee::net_utils::parse_url(s, url);
- }
- catch (const std::exception &e)
- {
- std::cerr << "Failed to load from binary: " << e.what() << std::endl;
- return 1;
- }
- return 0;
-}
-
-int main(int argc, const char **argv)
-{
- TRY_ENTRY();
- ParseURLFuzzer fuzzer;
- return run_fuzzer(argc, argv, fuzzer);
- CATCH_ENTRY_L0("main", 1);
-}
+BEGIN_INIT_SIMPLE_FUZZER()
+END_INIT_SIMPLE_FUZZER()
+BEGIN_SIMPLE_FUZZER()
+ epee::net_utils::http::url_content url;
+ epee::net_utils::parse_url(std::string((const char*)buf, len), url);
+END_SIMPLE_FUZZER()