22 std::optional<BufferedFile> opt_buffered_file;
24 fuzzed_file_provider.open(),
25 ConsumeRandomLengthByteVector<std::byte>(fuzzed_data_provider),
28 auto n_buf_size = fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096);
29 auto n_rewind_in = fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096);
30 opt_buffered_file.emplace(fuzzed_file, n_buf_size, n_rewind_in);
31 }
catch (
const std::ios_base::failure&) {
33 if (opt_buffered_file && !fuzzed_file.IsNull()) {
34 bool setpos_fail =
false;
40 std::array<std::byte, 4096> arr{};
42 opt_buffered_file->read({arr.data(), fuzzed_data_provider.ConsumeIntegralInRange<
size_t>(0, 4096)});
43 }
catch (
const std::ios_base::failure&) {
47 opt_buffered_file->SetLimit(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096));
50 if (!opt_buffered_file->SetPos(fuzzed_data_provider.ConsumeIntegralInRange<uint64_t>(0, 4096))) {
60 opt_buffered_file->FindByte(std::byte(fuzzed_data_provider.ConsumeIntegral<uint8_t>()));
61 }
catch (
const std::ios_base::failure&) {
68 opt_buffered_file->GetPos();
void ReadFromStream(AddrMan &addr, DataStream &ssPeers)
Only used by tests.
FUZZ_TARGET(buffered_file)
Non-refcounted RAII wrapper for FILE*.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)