mirror of
https://github.com/monero-project/monero.git
synced 2025-12-11 01:21:28 +09:00
commit
8a53c96b12
@ -32,26 +32,26 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||||||
FuzzedDataProvider provider(data, size);
|
FuzzedDataProvider provider(data, size);
|
||||||
|
|
||||||
// Randomly choose multiple fuzz_targets to fuzz
|
// Randomly choose multiple fuzz_targets to fuzz
|
||||||
int rpc_messages_to_send = provider.ConsumeIntegralInRange<int>(1, 16);
|
unsigned rpc_messages_to_send = provider.ConsumeIntegralInRange<unsigned>(1, 16);
|
||||||
std::vector<int> selectors;
|
std::vector<unsigned> selectors;
|
||||||
if (is_safe_mode) {
|
if (is_safe_mode) {
|
||||||
selectors.reserve(rpc_messages_to_send);
|
selectors.reserve(rpc_messages_to_send);
|
||||||
} else {
|
} else {
|
||||||
selectors.reserve(rpc_messages_to_send + priority_fuzz_targets.size());
|
selectors.reserve(rpc_messages_to_send + priority_fuzz_targets.size());
|
||||||
for (int i = 0; i < priority_fuzz_targets.size(); ++i) {
|
for (unsigned i = 0; i < priority_fuzz_targets.size(); ++i) {
|
||||||
selectors.push_back(i);
|
selectors.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Randomly shuffle the selectors for priority fuzz targets
|
// Randomly shuffle the selectors for priority fuzz targets
|
||||||
for (int i = 0; i < priority_fuzz_targets.size(); i++) {
|
for (unsigned i = 0; i < priority_fuzz_targets.size(); i++) {
|
||||||
int target = provider.ConsumeIntegralInRange<int>(0, priority_fuzz_targets.size() - 1);
|
unsigned target = provider.ConsumeIntegralInRange<unsigned>(0, priority_fuzz_targets.size() - 1);
|
||||||
std::swap(selectors[i], selectors[target]);
|
std::swap(selectors[i], selectors[target]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Randomly select rpc functions to call
|
// Randomly select rpc functions to call
|
||||||
for (int i = 0; i < rpc_messages_to_send && provider.remaining_bytes() >= 2; ++i) {
|
for (unsigned i = 0; i < rpc_messages_to_send && provider.remaining_bytes() >= 2; ++i) {
|
||||||
int selector = provider.ConsumeIntegralInRange<int>(0, fuzz_targets.size() - 1);
|
unsigned selector = provider.ConsumeIntegralInRange<unsigned>(0, fuzz_targets.size() - 1);
|
||||||
selectors.push_back(selector);
|
selectors.push_back(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
|||||||
// Disable bootstrap daemon
|
// Disable bootstrap daemon
|
||||||
disable_bootstrap_daemon(*rpc_handler->rpc);
|
disable_bootstrap_daemon(*rpc_handler->rpc);
|
||||||
|
|
||||||
for (int selector : selectors) {
|
for (unsigned selector : selectors) {
|
||||||
try {
|
try {
|
||||||
// Fuzz the target function
|
// Fuzz the target function
|
||||||
fuzz_targets[selector](*rpc_handler->rpc, provider);
|
fuzz_targets[selector](*rpc_handler->rpc, provider);
|
||||||
|
|||||||
@ -338,13 +338,10 @@ bool generate_random_blocks(cryptonote::core& core, FuzzedDataProvider& provider
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool added_txs = false;
|
|
||||||
for (const auto& tx_blob : cached_txs) {
|
for (const auto& tx_blob : cached_txs) {
|
||||||
cryptonote::tx_verification_context tvc;
|
cryptonote::tx_verification_context tvc;
|
||||||
bool accepted = core.handle_incoming_tx(tx_blob, tvc, cryptonote::relay_method::block, true);
|
bool accepted = core.handle_incoming_tx(tx_blob, tvc, cryptonote::relay_method::block, true);
|
||||||
if (accepted || tvc.m_added_to_pool) {
|
if (accepted || tvc.m_added_to_pool) {
|
||||||
added_txs = true;
|
|
||||||
|
|
||||||
// Store legit hashes
|
// Store legit hashes
|
||||||
cryptonote::transaction tx;
|
cryptonote::transaction tx;
|
||||||
if (cryptonote::parse_and_validate_tx_from_blob(tx_blob, tx)) {
|
if (cryptonote::parse_and_validate_tx_from_blob(tx_blob, tx)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user