23 std::optional<BufferedFile> opt_buffered_file;
24 const auto key_bytes{ConsumeFixedLengthByteVector<std::byte>(fuzzed_data_provider,
Obfuscation::KEY_SIZE)};
26 fuzzed_file_provider.open(),
30 auto n_buf_size = fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096);
31 auto n_rewind_in = fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096);
32 opt_buffered_file.emplace(fuzzed_file, n_buf_size, n_rewind_in);
33 }
catch (
const std::ios_base::failure&) {
35 if (opt_buffered_file && !fuzzed_file.IsNull()) {
36 bool setpos_fail =
false;
42 std::array<std::byte, 4096> arr{};
44 opt_buffered_file->read({arr.data(), fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(0, 4096)});
45 }
catch (
const std::ios_base::failure&) {
49 opt_buffered_file->SetLimit(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096));
52 if (!opt_buffered_file->SetPos(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096))) {
62 opt_buffered_file->FindByte(std::byte(fuzzed_data_provider.ConsumeIntegral<uint8_t>()));
63 }
catch (
const std::ios_base::failure&) {
70 opt_buffered_file->GetPos();
void ReadFromStream(AddrMan &addr, DataStream &ssPeers)
Only used by tests.
FUZZ_TARGET(buffered_file)
Non-refcounted RAII wrapper for FILE*.
static constexpr size_t KEY_SIZE
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)