mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
fuzz_tests: refactor and add OSS-Fuzz compatibility
This commit is contained in:
parent
77a008f714
commit
81773f55a4
16 changed files with 232 additions and 538 deletions
|
@ -262,6 +262,12 @@ else()
|
||||||
endif()
|
endif()
|
||||||
option(BUILD_DEBUG_UTILITIES "Build debug utilities." DEFAULT_BUILD_DEBUG_UTILITIES)
|
option(BUILD_DEBUG_UTILITIES "Build debug utilities." DEFAULT_BUILD_DEBUG_UTILITIES)
|
||||||
|
|
||||||
|
if(OSSFUZZ)
|
||||||
|
message(STATUS "Using OSS-Fuzz fuzzing system")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DOSSFUZZ")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOSSFUZZ")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Check whether we're on a 32-bit or 64-bit system
|
# Check whether we're on a 32-bit or 64-bit system
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL "8")
|
if(CMAKE_SIZEOF_VOID_P EQUAL "8")
|
||||||
set(DEFAULT_BUILD_64 ON)
|
set(DEFAULT_BUILD_64 ON)
|
||||||
|
|
|
@ -34,7 +34,8 @@ target_link_libraries(block_fuzz_tests
|
||||||
epee
|
epee
|
||||||
device
|
device
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET block_fuzz_tests
|
set_property(TARGET block_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -47,7 +48,8 @@ target_link_libraries(transaction_fuzz_tests
|
||||||
epee
|
epee
|
||||||
device
|
device
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET transaction_fuzz_tests
|
set_property(TARGET transaction_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -61,7 +63,8 @@ target_link_libraries(signature_fuzz_tests
|
||||||
epee
|
epee
|
||||||
device
|
device
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET signature_fuzz_tests
|
set_property(TARGET signature_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -75,7 +78,8 @@ target_link_libraries(cold-outputs_fuzz_tests
|
||||||
epee
|
epee
|
||||||
device
|
device
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET cold-outputs_fuzz_tests
|
set_property(TARGET cold-outputs_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -89,7 +93,8 @@ target_link_libraries(cold-transaction_fuzz_tests
|
||||||
epee
|
epee
|
||||||
device
|
device
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET cold-transaction_fuzz_tests
|
set_property(TARGET cold-transaction_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -101,7 +106,8 @@ target_link_libraries(load-from-binary_fuzz_tests
|
||||||
epee
|
epee
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET load-from-binary_fuzz_tests
|
set_property(TARGET load-from-binary_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -113,7 +119,8 @@ target_link_libraries(load-from-json_fuzz_tests
|
||||||
epee
|
epee
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET load-from-json_fuzz_tests
|
set_property(TARGET load-from-json_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -125,7 +132,8 @@ target_link_libraries(base58_fuzz_tests
|
||||||
epee
|
epee
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET base58_fuzz_tests
|
set_property(TARGET base58_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -138,7 +146,8 @@ target_link_libraries(parse-url_fuzz_tests
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${Boost_SYSTEM_LIBRARY}
|
${Boost_SYSTEM_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET parse-url_fuzz_tests
|
set_property(TARGET parse-url_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -153,7 +162,8 @@ target_link_libraries(http-client_fuzz_tests
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${Boost_SYSTEM_LIBRARY}
|
${Boost_SYSTEM_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET http-client_fuzz_tests
|
set_property(TARGET http-client_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -168,7 +178,8 @@ target_link_libraries(levin_fuzz_tests
|
||||||
${Boost_REGEX_LIBRARY}
|
${Boost_REGEX_LIBRARY}
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET levin_fuzz_tests
|
set_property(TARGET levin_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
@ -183,7 +194,8 @@ target_link_libraries(bulletproof_fuzz_tests
|
||||||
${Boost_REGEX_LIBRARY}
|
${Boost_REGEX_LIBRARY}
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${EXTRA_LIBRARIES})
|
${EXTRA_LIBRARIES}
|
||||||
|
$ENV{LIB_FUZZING_ENGINE})
|
||||||
set_property(TARGET bulletproof_fuzz_tests
|
set_property(TARGET bulletproof_fuzz_tests
|
||||||
PROPERTY
|
PROPERTY
|
||||||
FOLDER "tests")
|
FOLDER "tests")
|
||||||
|
|
|
@ -27,50 +27,13 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "include_base_utils.h"
|
#include "include_base_utils.h"
|
||||||
#include "file_io_utils.h"
|
|
||||||
#include "common/base58.h"
|
#include "common/base58.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class Base58Fuzzer: public Fuzzer
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
{
|
END_INIT_SIMPLE_FUZZER()
|
||||||
public:
|
|
||||||
Base58Fuzzer() {}
|
|
||||||
virtual int init();
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
};
|
|
||||||
|
|
||||||
int Base58Fuzzer::init()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Base58Fuzzer::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
|
|
||||||
{
|
|
||||||
std::string data;
|
|
||||||
tools::base58::decode(s, data);
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
Base58Fuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
BEGIN_SIMPLE_FUZZER()
|
||||||
|
std::string data;
|
||||||
|
tools::base58::decode(std::string((const char*)buf, len), data);
|
||||||
|
END_SIMPLE_FUZZER()
|
||||||
|
|
|
@ -33,36 +33,10 @@
|
||||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class BlockFuzzer: public Fuzzer
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
{
|
END_INIT_SIMPLE_FUZZER()
|
||||||
public:
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
|
|
||||||
private:
|
BEGIN_SIMPLE_FUZZER()
|
||||||
};
|
|
||||||
|
|
||||||
int BlockFuzzer::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;
|
|
||||||
}
|
|
||||||
cryptonote::block b = AUTO_VAL_INIT(b);
|
cryptonote::block b = AUTO_VAL_INIT(b);
|
||||||
if(!parse_and_validate_block_from_blob(s, b))
|
parse_and_validate_block_from_blob(std::string((const char*)buf, len), b);
|
||||||
{
|
END_SIMPLE_FUZZER()
|
||||||
std::cout << "Error: failed to parse block from file " << filename << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
TRY_ENTRY();
|
|
||||||
BlockFuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,40 +33,13 @@
|
||||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class BulletproofFuzzer: public Fuzzer
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
{
|
END_INIT_SIMPLE_FUZZER()
|
||||||
public:
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
|
|
||||||
private:
|
BEGIN_SIMPLE_FUZZER()
|
||||||
};
|
|
||||||
|
|
||||||
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;
|
std::stringstream ss;
|
||||||
ss << s;
|
ss << std::string((const char*)buf, len);
|
||||||
binary_archive<false> ba(ss);
|
binary_archive<false> ba(ss);
|
||||||
rct::Bulletproof proof = AUTO_VAL_INIT(proof);
|
rct::Bulletproof proof = AUTO_VAL_INIT(proof);
|
||||||
bool r = ::serialization::serialize(ba, proof);
|
::serialization::serialize(ba, proof);
|
||||||
if(!r)
|
END_SIMPLE_FUZZER()
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
|
@ -34,70 +34,25 @@
|
||||||
#include "wallet/wallet2.h"
|
#include "wallet/wallet2.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class ColdOutputsFuzzer: public Fuzzer
|
static tools::wallet2 wallet;
|
||||||
{
|
|
||||||
public:
|
|
||||||
ColdOutputsFuzzer(): wallet(cryptonote::TESTNET) {}
|
|
||||||
virtual int init();
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
|
|
||||||
private:
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
tools::wallet2 wallet;
|
|
||||||
};
|
|
||||||
|
|
||||||
int ColdOutputsFuzzer::init()
|
|
||||||
{
|
|
||||||
static const char * const spendkey_hex = "0b4f47697ec99c3de6579304e5f25c68b07afbe55b71d99620bf6cbf4e45a80f";
|
static const char * const spendkey_hex = "0b4f47697ec99c3de6579304e5f25c68b07afbe55b71d99620bf6cbf4e45a80f";
|
||||||
crypto::secret_key spendkey;
|
crypto::secret_key spendkey;
|
||||||
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
|
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
|
||||||
|
|
||||||
try
|
wallet.init("", boost::none, boost::asio::ip::tcp::endpoint{}, 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
||||||
{
|
wallet.set_subaddress_lookahead(1, 1);
|
||||||
wallet.init("", boost::none, boost::asio::ip::tcp::endpoint{}, 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
wallet.generate("", "", spendkey, true, false);
|
||||||
wallet.set_subaddress_lookahead(1, 1);
|
END_INIT_SIMPLE_FUZZER()
|
||||||
wallet.generate("", "", spendkey, true, false);
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
std::cerr << "Error on ColdOutputsFuzzer::init: " << e.what() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ColdOutputsFuzzer::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;
|
|
||||||
}
|
|
||||||
s = std::string("\x01\x16serialization::archive") + s;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::pair<size_t, std::vector<tools::wallet2::transfer_details>> outputs;
|
|
||||||
std::stringstream iss;
|
|
||||||
iss << s;
|
|
||||||
boost::archive::portable_binary_iarchive ar(iss);
|
|
||||||
ar >> outputs;
|
|
||||||
size_t n_outputs = wallet.import_outputs(outputs);
|
|
||||||
std::cout << boost::lexical_cast<std::string>(n_outputs) << " outputs imported" << std::endl;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
std::cerr << "Failed to import outputs: " << e.what() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
TRY_ENTRY();
|
|
||||||
ColdOutputsFuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
BEGIN_SIMPLE_FUZZER()
|
||||||
|
std::string s = std::string("\x01\x16serialization::archive") + std::string((const char*)buf, len);
|
||||||
|
std::pair<size_t, std::vector<tools::wallet2::transfer_details>> outputs;
|
||||||
|
std::stringstream iss;
|
||||||
|
iss << s;
|
||||||
|
boost::archive::portable_binary_iarchive ar(iss);
|
||||||
|
ar >> outputs;
|
||||||
|
size_t n_outputs = wallet.import_outputs(outputs);
|
||||||
|
std::cout << boost::lexical_cast<std::string>(n_outputs) << " outputs imported" << std::endl;
|
||||||
|
END_SIMPLE_FUZZER()
|
||||||
|
|
|
@ -34,71 +34,26 @@
|
||||||
#include "wallet/wallet2.h"
|
#include "wallet/wallet2.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class ColdTransactionFuzzer: public Fuzzer
|
static tools::wallet2 wallet;
|
||||||
{
|
|
||||||
public:
|
|
||||||
ColdTransactionFuzzer(): wallet(cryptonote::TESTNET) {}
|
|
||||||
virtual int init();
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
|
|
||||||
private:
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
tools::wallet2 wallet;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
int ColdTransactionFuzzer::init()
|
|
||||||
{
|
|
||||||
static const char * const spendkey_hex = "0b4f47697ec99c3de6579304e5f25c68b07afbe55b71d99620bf6cbf4e45a80f";
|
static const char * const spendkey_hex = "0b4f47697ec99c3de6579304e5f25c68b07afbe55b71d99620bf6cbf4e45a80f";
|
||||||
crypto::secret_key spendkey;
|
crypto::secret_key spendkey;
|
||||||
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
|
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
|
||||||
|
|
||||||
try
|
wallet.init("", boost::none, boost::asio::ip::tcp::endpoint{}, 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
||||||
{
|
wallet.set_subaddress_lookahead(1, 1);
|
||||||
wallet.init("", boost::none, boost::asio::ip::tcp::endpoint{}, 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
wallet.generate("", "", spendkey, true, false);
|
||||||
wallet.set_subaddress_lookahead(1, 1);
|
END_INIT_SIMPLE_FUZZER()
|
||||||
wallet.generate("", "", spendkey, true, false);
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
std::cerr << "Error on ColdTransactionFuzzer::init: " << e.what() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ColdTransactionFuzzer::run(const std::string &filename)
|
BEGIN_SIMPLE_FUZZER()
|
||||||
{
|
std::string s = std::string("\x01\x16serialization::archive") + std::string((const char*)buf, len);
|
||||||
std::string s;
|
tools::wallet2::unsigned_tx_set exported_txs;
|
||||||
|
std::stringstream iss;
|
||||||
if (!epee::file_io_utils::load_file_to_string(filename, s))
|
iss << s;
|
||||||
{
|
boost::archive::portable_binary_iarchive ar(iss);
|
||||||
std::cout << "Error: failed to load file " << filename << std::endl;
|
ar >> exported_txs;
|
||||||
return 1;
|
std::vector<tools::wallet2::pending_tx> ptx;
|
||||||
}
|
bool success = wallet.sign_tx(exported_txs, "/tmp/cold-transaction-test-signed", ptx);
|
||||||
s = std::string("\x01\x16serialization::archive") + s;
|
std::cout << (success ? "signed" : "error") << std::endl;
|
||||||
try
|
END_SIMPLE_FUZZER()
|
||||||
{
|
|
||||||
tools::wallet2::unsigned_tx_set exported_txs;
|
|
||||||
std::stringstream iss;
|
|
||||||
iss << s;
|
|
||||||
boost::archive::portable_binary_iarchive ar(iss);
|
|
||||||
ar >> exported_txs;
|
|
||||||
std::vector<tools::wallet2::pending_tx> ptx;
|
|
||||||
bool success = wallet.sign_tx(exported_txs, "/tmp/cold-transaction-test-signed", ptx);
|
|
||||||
std::cout << (success ? "signed" : "error") << std::endl;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
|
||||||
std::cerr << "Failed to sign transaction: " << e.what() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
TRY_ENTRY();
|
|
||||||
ColdTransactionFuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,6 +33,8 @@
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
|
#ifndef OSSFUZZ
|
||||||
|
|
||||||
#if (!defined(__clang__) || (__clang__ < 5))
|
#if (!defined(__clang__) || (__clang__ < 5))
|
||||||
static int __AFL_LOOP(int)
|
static int __AFL_LOOP(int)
|
||||||
{
|
{
|
||||||
|
@ -74,3 +76,5 @@ int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer)
|
||||||
|
|
||||||
CATCH_ENTRY_L0("run_fuzzer", 1);
|
CATCH_ENTRY_L0("run_fuzzer", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -27,6 +27,52 @@
|
||||||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "file_io_utils.h"
|
||||||
|
|
||||||
|
#ifdef OSSFUZZ
|
||||||
|
|
||||||
|
#define BEGIN_INIT_SIMPLE_FUZZER() \
|
||||||
|
static int init() \
|
||||||
|
{ \
|
||||||
|
try \
|
||||||
|
{
|
||||||
|
|
||||||
|
#define END_INIT_SIMPLE_FUZZER() \
|
||||||
|
} \
|
||||||
|
catch (const std::exception &e) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, "Exception: %s\n", e.what()); \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
return 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BEGIN_SIMPLE_FUZZER() \
|
||||||
|
extern "C" { \
|
||||||
|
int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len) \
|
||||||
|
{ \
|
||||||
|
try \
|
||||||
|
{ \
|
||||||
|
static bool first = true; \
|
||||||
|
if (first) \
|
||||||
|
{ \
|
||||||
|
if (!init()) \
|
||||||
|
return 1; \
|
||||||
|
first = false; \
|
||||||
|
} \
|
||||||
|
|
||||||
|
#define END_SIMPLE_FUZZER() \
|
||||||
|
} \
|
||||||
|
catch (const std::exception &e) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, "Exception: %s\n", e.what()); \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
class Fuzzer
|
class Fuzzer
|
||||||
{
|
{
|
||||||
|
@ -36,3 +82,57 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer);
|
int run_fuzzer(int argc, const char **argv, Fuzzer &fuzzer);
|
||||||
|
|
||||||
|
#define BEGIN_INIT_SIMPLE_FUZZER() \
|
||||||
|
class SimpleFuzzer: public Fuzzer \
|
||||||
|
{ \
|
||||||
|
virtual int init() \
|
||||||
|
{ \
|
||||||
|
try \
|
||||||
|
{
|
||||||
|
|
||||||
|
#define END_INIT_SIMPLE_FUZZER() \
|
||||||
|
} \
|
||||||
|
catch (const std::exception &e) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, "Exception: %s\n", e.what()); \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
return 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BEGIN_SIMPLE_FUZZER() \
|
||||||
|
virtual int run(const std::string &filename) \
|
||||||
|
{ \
|
||||||
|
try \
|
||||||
|
{ \
|
||||||
|
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; \
|
||||||
|
} \
|
||||||
|
const uint8_t *buf = (const uint8_t*)s.data(); \
|
||||||
|
const size_t len = s.size(); \
|
||||||
|
{
|
||||||
|
|
||||||
|
#define END_SIMPLE_FUZZER() \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
catch (const std::exception &e) \
|
||||||
|
{ \
|
||||||
|
fprintf(stderr, "Exception: %s\n", e.what()); \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
return 0; \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
int main(int argc, const char **argv) \
|
||||||
|
{ \
|
||||||
|
TRY_ENTRY(); \
|
||||||
|
SimpleFuzzer fuzzer; \
|
||||||
|
return run_fuzzer(argc, argv, fuzzer); \
|
||||||
|
CATCH_ENTRY_L0("main", 1); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -58,48 +58,11 @@ private:
|
||||||
std::string data;
|
std::string data;
|
||||||
};
|
};
|
||||||
|
|
||||||
class HTTPClientFuzzer: public Fuzzer
|
static epee::net_utils::http::http_simple_client_template<dummy_client> client;
|
||||||
{
|
|
||||||
public:
|
|
||||||
HTTPClientFuzzer() {}
|
|
||||||
virtual int init();
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
|
|
||||||
private:
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
epee::net_utils::http::http_simple_client_template<dummy_client> client;
|
END_INIT_SIMPLE_FUZZER()
|
||||||
};
|
|
||||||
|
|
||||||
int HTTPClientFuzzer::init()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int HTTPClientFuzzer::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
|
|
||||||
{
|
|
||||||
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_SIMPLE_FUZZER()
|
||||||
|
client.test(std::string((const char*)buf, len), std::chrono::milliseconds(1000));
|
||||||
|
END_SIMPLE_FUZZER()
|
||||||
|
|
|
@ -279,26 +279,10 @@ namespace
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
class LevinFuzzer: public Fuzzer
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
{
|
END_INIT_SIMPLE_FUZZER()
|
||||||
public:
|
|
||||||
LevinFuzzer() {} //: handler(endpoint, config, context) {}
|
|
||||||
virtual int init();
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
|
|
||||||
private:
|
BEGIN_SIMPLE_FUZZER()
|
||||||
//epee::net_utils::connection_context_base context;
|
|
||||||
//epee::levin::async_protocol_handler<> handler;
|
|
||||||
};
|
|
||||||
|
|
||||||
int LevinFuzzer::init()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int LevinFuzzer::run(const std::string &filename)
|
|
||||||
{
|
|
||||||
std::string s;
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
epee::levin::bucket_head2 req_head;
|
epee::levin::bucket_head2 req_head;
|
||||||
|
@ -313,13 +297,6 @@ int LevinFuzzer::run(const std::string &filename)
|
||||||
fwrite(&req_head,sizeof(req_head),1, f);
|
fwrite(&req_head,sizeof(req_head),1, f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
#endif
|
#endif
|
||||||
if (!epee::file_io_utils::load_file_to_string(filename, s))
|
|
||||||
{
|
|
||||||
std::cout << "Error: failed to load file " << filename << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//std::unique_ptr<test_connection> conn = new test();
|
//std::unique_ptr<test_connection> conn = new test();
|
||||||
boost::asio::io_service io_service;
|
boost::asio::io_service io_service;
|
||||||
test_levin_protocol_handler_config m_handler_config;
|
test_levin_protocol_handler_config m_handler_config;
|
||||||
|
@ -329,21 +306,5 @@ int LevinFuzzer::run(const std::string &filename)
|
||||||
conn->start();
|
conn->start();
|
||||||
//m_commands_handler.invoke_out_buf(expected_out_data);
|
//m_commands_handler.invoke_out_buf(expected_out_data);
|
||||||
//m_commands_handler.return_code(expected_return_code);
|
//m_commands_handler.return_code(expected_return_code);
|
||||||
conn->m_protocol_handler.handle_recv(s.data(), s.size());
|
conn->m_protocol_handler.handle_recv(buf, len);
|
||||||
}
|
END_SIMPLE_FUZZER()
|
||||||
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();
|
|
||||||
LevinFuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -33,46 +33,10 @@
|
||||||
#include "storages/portable_storage_base.h"
|
#include "storages/portable_storage_base.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class PortableStorageFuzzer: public Fuzzer
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
{
|
END_INIT_SIMPLE_FUZZER()
|
||||||
public:
|
|
||||||
PortableStorageFuzzer() {}
|
|
||||||
virtual int init();
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
};
|
|
||||||
|
|
||||||
int PortableStorageFuzzer::init()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PortableStorageFuzzer::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::serialization::portable_storage ps;
|
|
||||||
ps.load_from_binary(s);
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
PortableStorageFuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
BEGIN_SIMPLE_FUZZER()
|
||||||
|
epee::serialization::portable_storage ps;
|
||||||
|
ps.load_from_binary(std::string((const char*)buf, len));
|
||||||
|
END_SIMPLE_FUZZER()
|
||||||
|
|
|
@ -33,46 +33,10 @@
|
||||||
#include "storages/portable_storage_base.h"
|
#include "storages/portable_storage_base.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class PortableStorageFuzzer: public Fuzzer
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
{
|
END_INIT_SIMPLE_FUZZER()
|
||||||
public:
|
|
||||||
PortableStorageFuzzer() {}
|
|
||||||
virtual int init();
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
};
|
|
||||||
|
|
||||||
int PortableStorageFuzzer::init()
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int PortableStorageFuzzer::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::serialization::portable_storage ps;
|
|
||||||
ps.load_from_json(s);
|
|
||||||
}
|
|
||||||
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();
|
|
||||||
PortableStorageFuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
BEGIN_SIMPLE_FUZZER()
|
||||||
|
epee::serialization::portable_storage ps;
|
||||||
|
ps.load_from_json(std::string((const char*)buf, len));
|
||||||
|
END_SIMPLE_FUZZER()
|
||||||
|
|
|
@ -31,46 +31,10 @@
|
||||||
#include "net/net_parse_helpers.h"
|
#include "net/net_parse_helpers.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class ParseURLFuzzer: public Fuzzer
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
{
|
END_INIT_SIMPLE_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_SIMPLE_FUZZER()
|
||||||
|
epee::net_utils::http::url_content url;
|
||||||
|
epee::net_utils::parse_url(std::string((const char*)buf, len), url);
|
||||||
|
END_SIMPLE_FUZZER()
|
||||||
|
|
|
@ -34,66 +34,28 @@
|
||||||
#include "wallet/wallet2.h"
|
#include "wallet/wallet2.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class SignatureFuzzer: public Fuzzer
|
static tools::wallet2 wallet(cryptonote::TESTNET);
|
||||||
{
|
static cryptonote::account_public_address address;
|
||||||
public:
|
|
||||||
SignatureFuzzer(): Fuzzer(), wallet(cryptonote::TESTNET) {}
|
|
||||||
virtual int init();
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
|
|
||||||
private:
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
tools::wallet2 wallet;
|
|
||||||
cryptonote::account_public_address address;
|
|
||||||
};
|
|
||||||
|
|
||||||
int SignatureFuzzer::init()
|
|
||||||
{
|
|
||||||
static const char * const spendkey_hex = "0b4f47697ec99c3de6579304e5f25c68b07afbe55b71d99620bf6cbf4e45a80f";
|
static const char * const spendkey_hex = "0b4f47697ec99c3de6579304e5f25c68b07afbe55b71d99620bf6cbf4e45a80f";
|
||||||
crypto::secret_key spendkey;
|
crypto::secret_key spendkey;
|
||||||
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
|
epee::string_tools::hex_to_pod(spendkey_hex, spendkey);
|
||||||
|
|
||||||
try
|
wallet.init("", boost::none, boost::asio::ip::tcp::endpoint{}, 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
||||||
{
|
wallet.set_subaddress_lookahead(1, 1);
|
||||||
wallet.init("", boost::none, boost::asio::ip::tcp::endpoint{}, 0, true, epee::net_utils::ssl_support_t::e_ssl_support_disabled);
|
wallet.generate("", "", spendkey, true, false);
|
||||||
wallet.set_subaddress_lookahead(1, 1);
|
|
||||||
wallet.generate("", "", spendkey, true, false);
|
|
||||||
|
|
||||||
cryptonote::address_parse_info info;
|
cryptonote::address_parse_info info;
|
||||||
if (!cryptonote::get_account_address_from_str_or_url(info, cryptonote::TESTNET, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
|
if (!cryptonote::get_account_address_from_str_or_url(info, cryptonote::TESTNET, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
|
||||||
{
|
|
||||||
std::cerr << "failed to parse address" << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
address = info.address;
|
|
||||||
}
|
|
||||||
catch (const std::exception &e)
|
|
||||||
{
|
{
|
||||||
std::cerr << "Error on SignatureFuzzer::init: " << e.what() << std::endl;
|
std::cerr << "failed to parse address" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
address = info.address;
|
||||||
}
|
END_INIT_SIMPLE_FUZZER()
|
||||||
|
|
||||||
int SignatureFuzzer::run(const std::string &filename)
|
BEGIN_SIMPLE_FUZZER()
|
||||||
{
|
bool valid = wallet.verify("test", address, std::string((const char*)buf, len));
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool valid = wallet.verify("test", address, s);
|
|
||||||
std::cout << "Signature " << (valid ? "valid" : "invalid") << std::endl;
|
std::cout << "Signature " << (valid ? "valid" : "invalid") << std::endl;
|
||||||
|
END_SIMPLE_FUZZER()
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
TRY_ENTRY();
|
|
||||||
SignatureFuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,36 +33,10 @@
|
||||||
#include "cryptonote_basic/cryptonote_format_utils.h"
|
#include "cryptonote_basic/cryptonote_format_utils.h"
|
||||||
#include "fuzzer.h"
|
#include "fuzzer.h"
|
||||||
|
|
||||||
class TransactionFuzzer: public Fuzzer
|
BEGIN_INIT_SIMPLE_FUZZER()
|
||||||
{
|
END_INIT_SIMPLE_FUZZER()
|
||||||
public:
|
|
||||||
virtual int run(const std::string &filename);
|
|
||||||
|
|
||||||
private:
|
BEGIN_SIMPLE_FUZZER()
|
||||||
};
|
|
||||||
|
|
||||||
int TransactionFuzzer::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;
|
|
||||||
}
|
|
||||||
cryptonote::transaction tx = AUTO_VAL_INIT(tx);
|
cryptonote::transaction tx = AUTO_VAL_INIT(tx);
|
||||||
if(!parse_and_validate_tx_from_blob(s, tx))
|
parse_and_validate_tx_from_blob(std::string((const char*)buf, len), tx);
|
||||||
{
|
END_SIMPLE_FUZZER()
|
||||||
std::cout << "Error: failed to parse transaction from file " << filename << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
TRY_ENTRY();
|
|
||||||
TransactionFuzzer fuzzer;
|
|
||||||
return run_fuzzer(argc, argv, fuzzer);
|
|
||||||
CATCH_ENTRY_L0("main", 1);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue