MFCMAPI supports fuzzing with libFuzzer and the fsanitize switch in Visual Studio. See fuzz.cpp for implementation details.
- Visual Studio 2026 with the Fuzz build configuration
- PowerShell for corpus generation
# 1. Generate the corpus (converts hex test data to binary)
npm run fuzz:corpus
# 2. Build the fuzz configuration
npm run build:fuzz
# 3. Run the fuzzer
npm run fuzzThe fuzzer needs binary input files. The unit test data is stored as hex strings in .dat files. Run the corpus builder to convert them:
npm run fuzz:corpusThis reads from UnitTest/SmartViewTestData/In/*.dat and writes binary files to fuzz/corpus/.
Note: You must run this before fuzzing. The corpus directory won't exist until you do.
npm run build:fuzz- Open
MFCMapi.slnin Visual Studio 2026 - Select Fuzz from the Solution Configurations dropdown
- Build the solution
- Run
pwsh .\fuzz\Build-FuzzingCorpus.ps1first (if you haven't already) - Open the Run and Debug panel (Ctrl+Shift+D)
- Select "Fuzz (x64)" or "Fuzz (x86)" from the configuration dropdown
- Press F5 to start
The fuzzer runs for 60 seconds by default.
To change the runtime in the debug panel, edit the selected fuzz entry in .vscode/launch.json and update the "-MaxTotalTime", "60" arguments.
npm run fuzz
# or
npm run fuzz:x86To run longer or shorter from command line:
npm run fuzz:x64 -- -MaxTotalTime 300
npm run fuzz:x86 -- -MaxTotalTime 120- Open
MFCMapi.slnin Visual Studio - Select the
fuzz/x64project (orfuzz/x86) - Press F5 to run
When the fuzzer discovers a crash or hang, it saves the input that caused it to fuzz/artifacts/. These files can be used to reproduce and debug the issue.