From 5dbaaea032f8bd950cee138c02a2500b1ab07fb8 Mon Sep 17 00:00:00 2001 From: Jakub Jelen Date: Thu, 7 May 2020 14:08:03 +0200 Subject: [PATCH] Improve OpenSC fuzzing (#3683) * opensc: Disable optimization to simplify debugging * opensc: Include initial corpus --- projects/opensc/build.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/projects/opensc/build.sh b/projects/opensc/build.sh index 212d34a6b..84ab497e7 100755 --- a/projects/opensc/build.sh +++ b/projects/opensc/build.sh @@ -17,12 +17,15 @@ ./bootstrap # FIXME FUZZING_LIBS="$LIB_FUZZING_ENGINE" fails with some missing C++ library, I don't know how to fix this -./configure --disable-shared --disable-pcsc --enable-ctapi --enable-fuzzing FUZZING_LIBS="$LIB_FUZZING_ENGINE" +./configure --disable-optimization --disable-shared --disable-pcsc --enable-ctapi --enable-fuzzing FUZZING_LIBS="$LIB_FUZZING_ENGINE" make -j4 -cp src/tests/fuzzing/fuzz_asn1_print $OUT -cp src/tests/fuzzing/fuzz_asn1_sig_value $OUT -cp src/tests/fuzzing/fuzz_pkcs15_decode $OUT -cp src/tests/fuzzing/fuzz_pkcs15_reader $OUT +fuzzerFiles=$(find $SRC/opensc/src/tests/fuzzing/ -name "fuzz_*.c") -#cp src/tests/fuzzing/fuzz_pkcs15_reader.options $OUT +for F in $fuzzerFiles; do + fuzzerName=$(basename $F .c) + cp "$SRC/opensc/src/tests/fuzzing/$fuzzerName" $OUT + if [ -d "$SRC/opensc/src/tests/fuzzing/corpus/${fuzzerName}" ]; then + zip -j $OUT/${fuzzerName}_seed_corpus.zip $SRC/opensc/src/tests/fuzzing/corpus/${fuzzerName}/* + fi +done