clamav_dbload_fuzzer.cpp and clamav_scanfile_fuzzer.cpp use __pid_t, which some
Apple systems do not define, and this causes a compilation error. This change
defines __pid_t as pid_t, which does exist on those systems and allows clamav
to build.
The fuzz targets that write a temp file currently use the same filename
every time. One of the users identified that if the tests are running
in parallel mode, many processes are accessing the same file.
This results in unstable input to the API being tested, where the file
may be overwritten as the function is being tested.
This commit fixes it by putting the fuzz process PID in the filenames
for the scanfile and dbload fuzz targets.
Resolves: https://github.com/Cisco-Talos/clamav/issues/432
Also fixed a CMake bug that built an extra fuzz target file that doesn't
serve any purpose.
Resolves: https://github.com/Cisco-Talos/clamav/issues/431
I found two issues with the cl_load fuzz targets, one of which impacts
the scanfile and scanmap fuzz targets:
1. We were defining the preprocessor definitions incorrectly using
"SCAN_TARGETS" instead of "TARGET" in unit_tests/CMakeLists.txt.
For the scan fuzz targets this meant it wasn't properly defining
unique settings for each compiled target.
For the cl_load fuzz target it's worse, it wasn't setting the
database file name correctly which means it rejected the filenames
entirely for not having a legitimate suffix.
2. We were pre-compiling the engine before loading signatures.
You can't load sigs for an engine that's already compiled, so this
would also fail right away without trying to load any sigs.