Cleanup fuzzing
This commit is contained in:
@@ -10,21 +10,19 @@
|
||||
|
||||
template <typename Item1, typename Item2>
|
||||
void invoke_fmt(const uint8_t* data, size_t size) {
|
||||
using fmt_fuzzer::nfixed;
|
||||
static_assert(sizeof(Item1) <= nfixed, "size1 exceeded");
|
||||
static_assert(sizeof(Item2) <= nfixed, "size2 exceeded");
|
||||
if (size <= nfixed + nfixed) return;
|
||||
static_assert(sizeof(Item1) <= fixed_size, "size1 exceeded");
|
||||
static_assert(sizeof(Item2) <= fixed_size, "size2 exceeded");
|
||||
if (size <= fixed_size + fixed_size) return;
|
||||
|
||||
const Item1 item1 = fmt_fuzzer::assignFromBuf<Item1>(data);
|
||||
data += nfixed;
|
||||
size -= nfixed;
|
||||
const Item1 item1 = assign_from_buf<Item1>(data);
|
||||
data += fixed_size;
|
||||
size -= fixed_size;
|
||||
|
||||
const Item2 item2 = fmt_fuzzer::assignFromBuf<Item2>(data);
|
||||
data += nfixed;
|
||||
size -= nfixed;
|
||||
|
||||
auto format_str = fmt::string_view(fmt_fuzzer::as_chars(data), size);
|
||||
const Item2 item2 = assign_from_buf<Item2>(data);
|
||||
data += fixed_size;
|
||||
size -= fixed_size;
|
||||
|
||||
auto format_str = fmt::string_view(as_chars(data), size);
|
||||
#if FMT_FUZZ_FORMAT_TO_STRING
|
||||
std::string message = fmt::format(format_str, item1, item2);
|
||||
#else
|
||||
@@ -91,13 +89,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
if (size <= 3) return 0;
|
||||
|
||||
// Switch types depending on the first byte of the input.
|
||||
const auto first = data[0] & 0x0F;
|
||||
const auto second = (data[0] & 0xF0) >> 4;
|
||||
const auto type1 = data[0] & 0x0F;
|
||||
const auto type2 = (data[0] & 0xF0) >> 4;
|
||||
data++;
|
||||
size--;
|
||||
try {
|
||||
invoke(first, [=](auto param1) {
|
||||
invoke(second, [=](auto param2) {
|
||||
invoke(type1, [=](auto param1) {
|
||||
invoke(type2, [=](auto param2) {
|
||||
invoke_fmt<decltype(param1), decltype(param2)>(data, size);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user