aboutsummaryrefslogtreecommitdiff
path: root/tests/fuzz
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fuzz')
-rw-r--r--tests/fuzz/CMakeLists.txt15
-rw-r--r--tests/fuzz/base58.cpp2
-rw-r--r--tests/fuzz/block.cpp2
-rw-r--r--tests/fuzz/bulletproof.cpp72
-rw-r--r--tests/fuzz/cold-outputs.cpp2
-rw-r--r--tests/fuzz/cold-transaction.cpp2
-rw-r--r--tests/fuzz/fuzzer.cpp8
-rw-r--r--tests/fuzz/http-client.cpp2
-rw-r--r--tests/fuzz/levin.cpp3
-rw-r--r--tests/fuzz/load_from_binary.cpp2
-rw-r--r--tests/fuzz/load_from_json.cpp2
-rw-r--r--tests/fuzz/parse_url.cpp2
-rw-r--r--tests/fuzz/signature.cpp3
-rw-r--r--tests/fuzz/transaction.cpp2
14 files changed, 119 insertions, 0 deletions
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
index dfbbaeca6..fdb745699 100644
--- a/tests/fuzz/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -173,3 +173,18 @@ set_property(TARGET levin_fuzz_tests
PROPERTY
FOLDER "tests")
+add_executable(bulletproof_fuzz_tests bulletproof.cpp fuzzer.cpp)
+target_link_libraries(bulletproof_fuzz_tests
+ PRIVATE
+ common
+ epee
+ ${Boost_THREAD_LIBRARY}
+ ${Boost_CHRONO_LIBRARY}
+ ${Boost_REGEX_LIBRARY}
+ ${Boost_PROGRAM_OPTIONS_LIBRARY}
+ ${CMAKE_THREAD_LIBS_INIT}
+ ${EXTRA_LIBRARIES})
+set_property(TARGET bulletproof_fuzz_tests
+ PROPERTY
+ FOLDER "tests")
+
diff --git a/tests/fuzz/base58.cpp b/tests/fuzz/base58.cpp
index 49516dd83..a4857bdd1 100644
--- a/tests/fuzz/base58.cpp
+++ b/tests/fuzz/base58.cpp
@@ -68,7 +68,9 @@ int Base58Fuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
Base58Fuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/block.cpp b/tests/fuzz/block.cpp
index 2df77b046..eed3b94b2 100644
--- a/tests/fuzz/block.cpp
+++ b/tests/fuzz/block.cpp
@@ -61,6 +61,8 @@ int BlockFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
BlockFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/bulletproof.cpp b/tests/fuzz/bulletproof.cpp
new file mode 100644
index 000000000..2f3a2f8d1
--- /dev/null
+++ b/tests/fuzz/bulletproof.cpp
@@ -0,0 +1,72 @@
+// Copyright (c) 2017-2018, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "include_base_utils.h"
+#include "file_io_utils.h"
+#include "cryptonote_basic/blobdatatype.h"
+#include "cryptonote_basic/cryptonote_basic.h"
+#include "cryptonote_basic/cryptonote_format_utils.h"
+#include "fuzzer.h"
+
+class BulletproofFuzzer: public Fuzzer
+{
+public:
+ virtual int run(const std::string &filename);
+
+private:
+};
+
+int BulletproofFuzzer::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;
+ }
+ std::stringstream ss;
+ ss << s;
+ binary_archive<false> ba(ss);
+ rct::Bulletproof proof = AUTO_VAL_INIT(proof);
+ bool r = ::serialization::serialize(ba, proof);
+ if(!r)
+ {
+ std::cout << "Error: failed to parse bulletproof from file " << filename << std::endl;
+ return 1;
+ }
+ return 0;
+}
+
+int main(int argc, const char **argv)
+{
+ TRY_ENTRY();
+ BulletproofFuzzer fuzzer;
+ return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
+}
diff --git a/tests/fuzz/cold-outputs.cpp b/tests/fuzz/cold-outputs.cpp
index 59b59810c..488a3b931 100644
--- a/tests/fuzz/cold-outputs.cpp
+++ b/tests/fuzz/cold-outputs.cpp
@@ -95,7 +95,9 @@ int ColdOutputsFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
ColdOutputsFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/cold-transaction.cpp b/tests/fuzz/cold-transaction.cpp
index da33dc318..fa3041ba3 100644
--- a/tests/fuzz/cold-transaction.cpp
+++ b/tests/fuzz/cold-transaction.cpp
@@ -97,6 +97,8 @@ int ColdTransactionFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
ColdTransactionFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/fuzzer.cpp b/tests/fuzz/fuzzer.cpp
index b81bf80fe..ab14e2b79 100644
--- a/tests/fuzz/fuzzer.cpp
+++ b/tests/fuzz/fuzzer.cpp
@@ -46,12 +46,18 @@ static int __AFL_LOOP(int)
int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer)
{
+ TRY_ENTRY();
+
if (argc < 2)
{
std::cout << "usage: " << argv[0] << " " << "<filename>" << std::endl;
return 1;
}
+#ifdef __AFL_HAVE_MANUAL_CONTROL
+ __AFL_INIT();
+#endif
+
int ret = fuzzer.init();
if (ret)
return ret;
@@ -65,4 +71,6 @@ int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer)
}
return 0;
+
+ CATCH_ENTRY_L0("run_fuzzer", 1);
}
diff --git a/tests/fuzz/http-client.cpp b/tests/fuzz/http-client.cpp
index cd52643d9..909325832 100644
--- a/tests/fuzz/http-client.cpp
+++ b/tests/fuzz/http-client.cpp
@@ -92,7 +92,9 @@ int HTTPClientFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
HTTPClientFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/levin.cpp b/tests/fuzz/levin.cpp
index 6a164dda9..d0c5803f5 100644
--- a/tests/fuzz/levin.cpp
+++ b/tests/fuzz/levin.cpp
@@ -158,6 +158,7 @@ namespace
}
virtual bool close() { return true; }
+ virtual bool send_done() { return true; }
virtual bool call_run_once_service_io() { return true; }
virtual bool request_callback() { return true; }
virtual boost::asio::io_service& get_io_service() { return m_io_service; }
@@ -340,7 +341,9 @@ int LevinFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
LevinFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/load_from_binary.cpp b/tests/fuzz/load_from_binary.cpp
index 8f96c454f..89f122902 100644
--- a/tests/fuzz/load_from_binary.cpp
+++ b/tests/fuzz/load_from_binary.cpp
@@ -70,7 +70,9 @@ int PortableStorageFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
PortableStorageFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/load_from_json.cpp b/tests/fuzz/load_from_json.cpp
index b0c1a9bf3..083555f7e 100644
--- a/tests/fuzz/load_from_json.cpp
+++ b/tests/fuzz/load_from_json.cpp
@@ -70,7 +70,9 @@ int PortableStorageFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
PortableStorageFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/parse_url.cpp b/tests/fuzz/parse_url.cpp
index 8812cf9c2..fb5754a70 100644
--- a/tests/fuzz/parse_url.cpp
+++ b/tests/fuzz/parse_url.cpp
@@ -68,7 +68,9 @@ int ParseURLFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
ParseURLFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/signature.cpp b/tests/fuzz/signature.cpp
index 7f22757b2..f82ada8b4 100644
--- a/tests/fuzz/signature.cpp
+++ b/tests/fuzz/signature.cpp
@@ -64,6 +64,7 @@ int SignatureFuzzer::init()
std::cerr << "failed to parse address" << std::endl;
return 1;
}
+ address = info.address;
}
catch (const std::exception &e)
{
@@ -91,6 +92,8 @@ int SignatureFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
SignatureFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}
diff --git a/tests/fuzz/transaction.cpp b/tests/fuzz/transaction.cpp
index b3349c383..934bd4685 100644
--- a/tests/fuzz/transaction.cpp
+++ b/tests/fuzz/transaction.cpp
@@ -61,6 +61,8 @@ int TransactionFuzzer::run(const std::string &filename)
int main(int argc, const char **argv)
{
+ TRY_ENTRY();
TransactionFuzzer fuzzer;
return run_fuzzer(argc, argv, fuzzer);
+ CATCH_ENTRY_L0("main", 1);
}