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

Function LLVMFuzzerTestOneInput

apps/fuzzers/Fuzzer/fuzz_wav.cpp:25–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
26{
27 // Force a valid "RIFF....WAVE" header so mutations reach the chunk walk +
28 // WAVEFORMATEX + sample read instead of bouncing at the RIFF/WAVE fourcc check.
29 static const uint8_t HDR[] = {'R', 'I', 'F', 'F', 0, 0, 0, 0, 'W', 'A', 'V', 'E'};
30 std::vector<uint8_t> buf = fuzz::ForceHeader(HDR, sizeof(HDR), data, size);
31 try
32 {
33 WaveStream* ws = SoundLoadMemory(buf.data(), buf.size(), ".wav");
34 if (ws)
35 {
36 WAVEFORMATEX fmt;
37 ws->GetFormat(fmt);
38 int total = ws->GetUncompressedSize();
39 int cap = (total < 0) ? 0 : std::min(total, 16 << 20); // bound the decoded read
40 std::vector<char> buf(4096);
41 for (int off = 0; off < cap; off += static_cast<int>(buf.size()))
42 {
43 ws->GetData(buf.data(), off, std::min(static_cast<int>(buf.size()), cap - off));
44 }
45 delete ws;
46 }
47 }
48 catch (...)
49 {
50 }
51 return 0;
52}

Callers

nothing calls this directly

Calls 7

ForceHeaderFunction · 0.85
SoundLoadMemoryFunction · 0.85
minFunction · 0.85
sizeMethod · 0.80
GetFormatMethod · 0.45
GetUncompressedSizeMethod · 0.45
GetDataMethod · 0.45

Tested by

no test coverage detected