aboutsummaryrefslogtreecommitdiff
path: root/tests/fuzz/http-client.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-05-27 18:27:06 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-05-27 18:27:06 -0500
commitd6d4a03b8599df3975eb351365273916b3d2f594 (patch)
treee13fd39b6b992a95d230565a84093b80e0fde9bb /tests/fuzz/http-client.cpp
parentMerge pull request #6531 (diff)
parentcmake: ASAN and PIE don't mix (diff)
downloadmonero-d6d4a03b8599df3975eb351365273916b3d2f594.tar.xz
Merge pull request #6535
81773f5 fuzz_tests: refactor and add OSS-Fuzz compatibility (moneromooo-monero) cb4edc1 cmake: ASAN and PIE don't mix (moneromooo-monero)
Diffstat (limited to 'tests/fuzz/http-client.cpp')
-rw-r--r--tests/fuzz/http-client.cpp49
1 files changed, 6 insertions, 43 deletions
diff --git a/tests/fuzz/http-client.cpp b/tests/fuzz/http-client.cpp
index ea6d5a2ad..1801affee 100644
--- a/tests/fuzz/http-client.cpp
+++ b/tests/fuzz/http-client.cpp
@@ -58,48 +58,11 @@ private:
std::string data;
};
-class HTTPClientFuzzer: public Fuzzer
-{
-public:
- HTTPClientFuzzer() {}
- virtual int init();
- virtual int run(const std::string &filename);
-
-private:
- epee::net_utils::http::http_simple_client_template<dummy_client> client;
-};
-
-int HTTPClientFuzzer::init()
-{
- return 0;
-}
-
-int HTTPClientFuzzer::run(const std::string &filename)
-{
- std::string s;
+static epee::net_utils::http::http_simple_client_template<dummy_client> client;
- if (!epee::file_io_utils::load_file_to_string(filename, s))
- {
- std::cout << "Error: failed to load file " << filename << std::endl;
- return 1;
- }
- try
- {
- client.test(s, std::chrono::milliseconds(1000));
- }
- catch (const std::exception &e)
- {
- std::cerr << "Failed to test http client: " << e.what() << std::endl;
- return 1;
- }
- return 0;
-}
-
-int main(int argc, const char **argv)
-{
- TRY_ENTRY();
- HTTPClientFuzzer fuzzer;
- return run_fuzzer(argc, argv, fuzzer);
- CATCH_ENTRY_L0("main", 1);
-}
+BEGIN_INIT_SIMPLE_FUZZER()
+END_INIT_SIMPLE_FUZZER()
+BEGIN_SIMPLE_FUZZER()
+ client.test(std::string((const char*)buf, len), std::chrono::milliseconds(1000));
+END_SIMPLE_FUZZER()