MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / read

Method read

src/test/fuzz/util.cpp:292–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292ssize_t FuzzedFileProvider::read(void* cookie, char* buf, size_t size)
293{
294 FuzzedFileProvider* fuzzed_file = (FuzzedFileProvider*)cookie;
295 SetFuzzedErrNo(fuzzed_file->m_fuzzed_data_provider);
296 if (buf == nullptr || size == 0 || fuzzed_file->m_fuzzed_data_provider.ConsumeBool()) {
297 return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1;
298 }
299 const std::vector<uint8_t> random_bytes = fuzzed_file->m_fuzzed_data_provider.ConsumeBytes<uint8_t>(size);
300 if (random_bytes.empty()) {
301 return 0;
302 }
303 std::memcpy(buf, random_bytes.data(), random_bytes.size());
304 if (AdditionOverflow(fuzzed_file->m_offset, (int64_t)random_bytes.size())) {
305 return fuzzed_file->m_fuzzed_data_provider.ConsumeBool() ? 0 : -1;
306 }
307 fuzzed_file->m_offset += random_bytes.size();
308 return random_bytes.size();
309}
310
311ssize_t FuzzedFileProvider::write(void* cookie, const char* buf, size_t size)
312{

Callers 15

IsBDBFileFunction · 0.45
IsSQLiteFileFunction · 0.45
UnserializeMethod · 0.45
UnserializeMethod · 0.45
UnserializeMethod · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
JSONFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
parse_univalue.cppFile · 0.45

Calls 6

SetFuzzedErrNoFunction · 0.85
AdditionOverflowFunction · 0.85
ConsumeBoolMethod · 0.80
emptyMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected