2023-07-25 11:53:09 +02:00
|
|
|
#include "group_moderation.h"
|
|
|
|
|
|
|
|
#include "../testing/fuzzing/fuzz_support.h"
|
2024-01-14 21:51:01 +01:00
|
|
|
#include "mem_test_util.hh"
|
2023-07-25 11:53:09 +02:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
void TestModListUnpack(Fuzz_Data &input)
|
|
|
|
{
|
2024-01-12 21:30:48 +01:00
|
|
|
CONSUME1_OR_RETURN(const uint16_t, num_mods, input);
|
2024-01-14 21:51:01 +01:00
|
|
|
Test_Memory mem;
|
|
|
|
Moderation mods{mem};
|
|
|
|
mod_list_unpack(&mods, input.data(), input.size(), num_mods);
|
2023-07-25 11:53:09 +02:00
|
|
|
mod_list_cleanup(&mods);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TestSanctionsListUnpack(Fuzz_Data &input)
|
|
|
|
{
|
|
|
|
Mod_Sanction sanctions[10];
|
|
|
|
Mod_Sanction_Creds creds;
|
|
|
|
uint16_t processed_data_len;
|
2024-01-14 21:51:01 +01:00
|
|
|
sanctions_list_unpack(sanctions, &creds, 10, input.data(), input.size(), &processed_data_len);
|
2023-07-25 11:53:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void TestSanctionCredsUnpack(Fuzz_Data &input)
|
|
|
|
{
|
|
|
|
CONSUME_OR_RETURN(const uint8_t *data, input, MOD_SANCTIONS_CREDS_SIZE);
|
|
|
|
Mod_Sanction_Creds creds;
|
|
|
|
sanctions_creds_unpack(&creds, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
|
|
|
{
|
2024-01-14 21:51:01 +01:00
|
|
|
fuzz_select_target<TestModListUnpack, TestSanctionsListUnpack, TestSanctionCredsUnpack>(
|
|
|
|
data, size);
|
2023-07-25 11:53:09 +02:00
|
|
|
return 0;
|
|
|
|
}
|