-
-
Notifications
You must be signed in to change notification settings - Fork 205
Expand file tree
/
Copy pathfuzz_tester.cpp
More file actions
28 lines (24 loc) · 731 Bytes
/
fuzz_tester.cpp
File metadata and controls
28 lines (24 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <cstddef>
#include <cstdint>
#include <fmt/core.h>//NOLINT
#include <iterator>
namespace {
[[nodiscard]] auto sum_values(const uint8_t *Data, size_t Size)
{
constexpr auto scale = 1000;
int value = 0;
for (std::size_t offset = 0; offset < Size; ++offset) {
value += static_cast<int>(*std::next(Data, static_cast<long>(offset))) * scale;
}
return value;
}
}// namespace
// Fuzzer that attempts to invoke undefined behavior for signed integer overflow
// cppcheck-suppress unusedFunction symbolName=LLVMFuzzerTestOneInput
namespace {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
{
fmt::print("Value sum: {}, len{}\n", sum_values(Data, Size), Size);
return 0;
}
}// namespace