MCPcopy Create free account
hub / github.com/ElementsProject/elements / seek

Method seek

src/test/fuzz/util.cpp:582–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

580}
581
582int FuzzedFileProvider::seek(void* cookie, int64_t* offset, int whence)
583{
584 assert(whence == SEEK_SET || whence == SEEK_CUR || whence == SEEK_END);
585 FuzzedFileProvider* fuzzed_file = (FuzzedFileProvider*)cookie;
586 SetFuzzedErrNo(fuzzed_file->m_fuzzed_data_provider);
587 int64_t new_offset = 0;
588 if (whence == SEEK_SET) {
589 new_offset = *offset;
590 } else if (whence == SEEK_CUR) {
591 if (AdditionOverflow(fuzzed_file->m_offset, *offset)) {
592 return -1;
593 }
594 new_offset = fuzzed_file->m_offset + *offset;
595 } else if (whence == SEEK_END) {
596 const int64_t n = fuzzed_file->m_fuzzed_data_provider.ConsumeIntegralInRange<int64_t>(0, 4096);
597 if (AdditionOverflow(n, *offset)) {
598 return -1;
599 }
600 new_offset = n + *offset;
601 }
602 if (new_offset < 0) {
603 return -1;
604 }
605 fuzzed_file->m_offset = new_offset;
606 *offset = new_offset;
607 return fuzzed_file->m_fuzzed_data_provider.ConsumeIntegralInRange<int>(-1, 0);
608}
609
610int FuzzedFileProvider::close(void* cookie)
611{

Callers 15

fetchBlockMethod · 0.45
runMethod · 0.45
process_fileFunction · 0.45
get_node_outputMethod · 0.45
get_nextMethod · 0.45
stop_nodeMethod · 0.45
assert_debug_logMethod · 0.45
get_node_outputMethod · 0.45
assert_is_bdbMethod · 0.45
get_nextMethod · 0.45
stop_nodeMethod · 0.45

Calls 2

SetFuzzedErrNoFunction · 0.85
AdditionOverflowFunction · 0.85

Tested by

no test coverage detected