MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / LLVMFuzzerTestOneInput

Function LLVMFuzzerTestOneInput

apps/fuzzers/Fuzzer/fuzz_wrp.cpp:31–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
32{
33 // WrpReader::Load dispatches on a 4-byte magic; raw mutations almost never hit one,
34 // so force a valid header. Pick OPRW (version 3) or the RVW family (64x64 grid) from
35 // an input byte so both format branches stay reachable.
36 std::vector<uint8_t> buf;
37 if (size && (data[0] & 1))
38 {
39 static const uint8_t H[] = {'O', 'P', 'R', 'W', 3, 0, 0, 0}; // OPRW v3
40 buf = fuzz::ForceHeader(H, sizeof(H), data, size);
41 }
42 else
43 {
44 static const uint8_t H[] = {'2', 'W', 'V', 'R', 64, 0, 0, 0, 64, 0, 0, 0}; // RVW v2, 64x64
45 buf = fuzz::ForceHeader(H, sizeof(H), data, size);
46 }
47 try
48 {
49 WrpReader reader;
50 QIStream f(reinterpret_cast<char*>(buf.data()), static_cast<int>(buf.size()));
51 reader.Load(f);
52 }
53 catch (...)
54 {
55 }
56 return 0;
57}

Callers

nothing calls this directly

Calls 3

ForceHeaderFunction · 0.85
sizeMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected