Rowan Hart 0b25d723c0
Windows Support for LibAFL-LibFuzzer (#3130)
* Add windows build script and additional changes to support windows for libafl-libfuzzer

* Update build scripts and harness wrapping directives

* Resolve issue with corpus edge count calculation

* Add help message and make fork do nothing on Windows

* Format harness_wrap.cpp

* Clippy happiness pass

* Clippy happiness pass

* Clippy happiness pass

* Correct logic

* Correct logic

* Update help output and make runs argument work

* Add test for libafl_libfuzzer on windows

* Add workflow for libafl_libfuzzer test

* Fix copy without dependent task

* Add libafl_libfuzzer_windows to preflight list

* Format harness

* Explicitly ignore windows fuzzer

* Remove windows-specific copy from unix instructions

* Ensure using nightly

* Fix job name

* Update build to use libFuzzer.lib on Windows to keep consistent with Linux

* Remove nightly requirement

---------

Co-authored-by: Rowan Hart <rowanhart@microsoft.com>
2025-05-21 01:35:48 +02:00

33 lines
770 B
C++

// Simple decoder function with an off by one error that is triggered under
// certain conditions.
#include <cstddef>
#include <cstdint>
int DecodeInput(const uint8_t *data, size_t size) {
if (size < 5) {
return -1; // Error: not enough data
}
if (data[0] != 'F' || data[1] != 'U' || data[2] != 'Z' || data[3] == 'Z') {
return -1; // Error: invalid header
}
if (data[4] <= 0) {
return -1; // Error: invalid size
}
int csum = 0;
for (size_t i = 5; i < size; ++i) {
csum += data[i];
}
return csum; // Error: checksum mismatch
}
extern "C" __declspec(dllexport) int LLVMFuzzerTestOneInput(const uint8_t *data,
size_t size) {
DecodeInput(data, size);
return 0;
}