libdwarf: add seeds and cleanup fuzzers tt only used public headers (#6795)

This commit is contained in:
DavidKorczynski 2021-11-07 23:39:24 +00:00 committed by GitHub
parent baa79e1e6d
commit 4d4111183b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 8 deletions

View File

@ -17,6 +17,7 @@
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y make autoconf automake libtool
RUN git clone --depth 1 https://github.com/davea42/libdwarf-code libdwarf
RUN git clone --depth=1 https://github.com/DavidKorczynski/binary-samples $SRC/binary-samples
WORKDIR libdwarf
COPY build.sh $SRC/
COPY fuzz*.c $SRC/

View File

@ -15,14 +15,24 @@
#
################################################################################
export CFLAGS="${CFLAGS} -g"
export CXXFLAGS="${CXXFLAGS} -g"
export CFLAGS="${CFLAGS} -g -Werror"
export CXXFLAGS="${CXXFLAGS} -g -Werror"
mkdir build
cd build
cmake ../
make
# Build corpus for fuzzing
mkdir $SRC/corp
cp $SRC/binary-samples/elf* $SRC/corp
cp $SRC/binary-samples/Mach* $SRC/corp
cp $SRC/binary-samples/pe* $SRC/corp
cp $SRC/binary-samples/lib* $SRC/corp
zip -r -j $OUT/fuzz_init_path_seed_corpus.zip $SRC/corp
cp $OUT/fuzz_init_path_seed_corpus.zip $OUT/fuzz_init_binary_seed_corpus.zip
for fuzzName in init_path init_binary; do
$CC $CFLAGS $LIB_FUZZING_ENGINE -I../src/lib/libdwarf/ \
$SRC/fuzz_${fuzzName}.c -o $OUT/fuzz_${fuzzName} ./src/lib/libdwarf/libdwarf.a

View File

@ -18,11 +18,11 @@ limitations under the License.
#include <fcntl.h>
#include <unistd.h>
/*
* Libdwarf library callers can only use these headers.
*/
#include "dwarf.h"
#include "libdwarf.h"
#include "libdwarf_private.h"
#include "dwarf_alloc.h"
/*
* A fuzzer that simulates a small part of the simplereader.c example.

View File

@ -16,11 +16,11 @@ limitations under the License.
#include <sys/types.h>
#include <unistd.h>
/*
* Libdwarf library callers can only use these headers.
*/
#include "dwarf.h"
#include "libdwarf.h"
#include "libdwarf_private.h"
#include "dwarf_alloc.h"
/*
* A fuzzer that simulates a small part of the simplereader.c example.