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

Function LLVMFuzzerTestOneInput

apps/fuzzers/Fuzzer/fuzz_wss.cpp:26–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

24}
25
26extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
27{
28 if (size < 1)
29 return 0;
30
31 // Force a valid WSS header with a chosen delta-pack mode so the BIS delta
32 // decompressor is actually exercised -- real seeds are uncompressed (deltaPack
33 // 0), so plain mutation almost never sets it. data[0] picks 0/4/8; the rest is
34 // the (attacker-controlled) WAVEFORMATEX + delta-packed audio payload.
35 static const unsigned char dpModes[] = {0, 4, 8};
36 std::vector<unsigned char> wss;
37 wss.reserve(size + 8);
38 wss.push_back('W');
39 wss.push_back('S');
40 wss.push_back('S');
41 wss.push_back('0');
42 wss.push_back(dpModes[data[0] % 3]);
43 wss.push_back(0); // resvd
44 wss.push_back(0);
45 wss.push_back(0);
46 wss.insert(wss.end(), data + 1, data + size);
47
48 try
49 {
50 WaveStream* ws = SoundLoadMemory(wss.data(), wss.size(), ".wss");
51 if (ws)
52 {
53 WAVEFORMATEX fmt;
54 ws->GetFormat(fmt);
55 int total = ws->GetUncompressedSize();
56 int cap = (total < 0) ? 0 : std::min(total, 16 << 20); // bound the decoded read
57 std::vector<char> buf(4096);
58 for (int off = 0; off < cap; off += static_cast<int>(buf.size()))
59 {
60 ws->GetData(buf.data(), off, std::min(static_cast<int>(buf.size()), cap - off));
61 }
62 delete ws;
63 }
64 }
65 catch (...)
66 {
67 }
68 return 0;
69}

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected