Dongjia "toka" Zhang 3ec8098d76
Remove duplicate corpus folders (#3174)
* remove duplicate pngs

* add tmin corpus back

* fix

* windows?

* space

* exit 0

* oops
2025-04-28 15:39:47 +02:00

97 lines
2.2 KiB
Makefile

FUZZER_NAME := 'fuzzer_libpng_nautilus'
PROJECT_DIR := absolute_path(".")
PROFILE := env("PROFILE", "release")
PROFILE_DIR := if PROFILE == "release" { "release" } else if PROFILE == "dev" { "debug" } else { "debug" }
CARGO_TARGET_DIR := env("CARGO_TARGET_DIR", "target")
FUZZER := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / FUZZER_NAME
LIBAFL_CC := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / "libafl_cc"
LIBAFL_CXX := PROJECT_DIR / CARGO_TARGET_DIR / PROFILE_DIR / "libafl_cxx"
alias cc := cxx
[linux]
[macos]
libpng:
#!/bin/bash
if [ ! -f v1.6.37.tar.gz ]; then
wget https://github.com/glennrp/libpng/archive/refs/tags/v1.6.37.tar.gz
fi
tar -xvf v1.6.37.tar.gz
[windows]
libpng:
echo "Unsupported on this platform"
[linux]
[macos]
cxx:
cargo build --profile {{PROFILE}}
[windows]
cxx:
echo "Unsupported on this platform"
[linux]
[macos]
lib: libpng cxx
#!/bin/bash
cd libpng-1.6.37 && ./configure --enable-shared=no --with-pic=yes --enable-hardware-optimizations=yes
cd {{PROJECT_DIR}}
make -C libpng-1.6.37 CC="{{LIBAFL_CC}}" CXX="{{LIBAFL_CXX}}"
[windows]
lib:
echo "Unsupported on this platform"
[linux]
[macos]
fuzzer: lib cxx
{{LIBAFL_CXX}} {{PROJECT_DIR}}/harness.cc {{PROJECT_DIR}}/libpng-1.6.37/.libs/libpng16.a -I {{PROJECT_DIR}}/libpng-1.6.37/ -o {{FUZZER_NAME}} -lm -lz
[windows]
fuzzer:
echo "Unsupported on this platform"
[linux]
[macos]
run: fuzzer
./{{FUZZER_NAME}} --cores 0
[windows]
run: fuzzer
echo "Unsupported on this platform"
[linux]
[macos]
run_unix_sync: fuzzer
./{{FUZZER_NAME}} --cores 0 -b 1337
[windows]
run_unix_sync: fuzzer
echo "Unsupported on this platform"
[linux]
[macos]
test: fuzzer
#!/bin/bash
rm -rf libafl_unix_shmem_server || true
timeout 31s ./{{FUZZER_NAME}} --cores 0 2>/dev/null | tee fuzz_stdout.log || true
if grep -qa "corpus: 8" fuzz_stdout.log; then
echo "Fuzzer is working"
else
echo "Fuzzer does not generate any testcases or any crashes"
exit 1
fi
[windows]
test: fuzzer
echo "Unsupported on this platform"
clean:
rm -rf {{FUZZER_NAME}}
make -C libpng-1.6.37 clean || true
cargo clean