diff --git a/projects/geos/Dockerfile b/projects/geos/Dockerfile index 1bf7fc1078f7..735e0afd3495 100644 --- a/projects/geos/Dockerfile +++ b/projects/geos/Dockerfile @@ -19,6 +19,4 @@ RUN apt-get update && apt-get install -y cmake # fallback to github if main git server is not responding RUN git clone --depth 1 https://git.osgeo.org/gitea/geos/geos.git || git clone --depth 1 https://github.com/libgeos/geos.git COPY run_tests.sh build.sh $SRC/ -COPY patch.diff $SRC WORKDIR $SRC/geos -RUN git apply ../patch.diff diff --git a/projects/geos/build.sh b/projects/geos/build.sh index 776ab84eb84e..d4edcb0f744d 100755 --- a/projects/geos/build.sh +++ b/projects/geos/build.sh @@ -21,3 +21,7 @@ cd build cmake -DBUILD_SHARED_LIBS=OFF .. make -j$(nproc) cp bin/fuzz* $OUT/ + +# Seed corpus and dictionary for the GeoJSON reader fuzzer. +cp $SRC/geos/tests/fuzz/geojson.dict $OUT/fuzz_geojson.dict +zip -j $OUT/fuzz_geojson_seed_corpus.zip $SRC/geos/tests/fuzz/geojson_seed_corpus/* diff --git a/projects/geos/patch.diff b/projects/geos/patch.diff deleted file mode 100644 index ab1a6aeb8700..000000000000 --- a/projects/geos/patch.diff +++ /dev/null @@ -1,105 +0,0 @@ -diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt -index 3401775c8..70af383b4 100644 ---- a/tests/CMakeLists.txt -+++ b/tests/CMakeLists.txt -@@ -10,3 +10,4 @@ - ################################################################################ - add_subdirectory(unit) - add_subdirectory(xmltester) -+add_subdirectory(fuzz) -diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt -new file mode 100644 -index 000000000..d0bd7a020 ---- /dev/null -+++ b/tests/fuzz/CMakeLists.txt -@@ -0,0 +1,15 @@ -+################################################################################ -+# Part of CMake configuration for GEOS -+# -+# Copyright (C) 2018 Mateusz Loskot -+# -+# This is free software; you can redistribute and/or modify it under -+# the terms of the GNU Lesser General Public Licence as published -+# by the Free Software Foundation. -+# See the COPYING file for more information. -+################################################################################ -+if(DEFINED ENV{LIB_FUZZING_ENGINE}) -+ add_executable(fuzz_geo2 fuzz_geo2.c) -+ target_include_directories(fuzz_geo2 PUBLIC $) -+ target_link_libraries(fuzz_geo2 geos_c $ENV{LIB_FUZZING_ENGINE}) -+endif() -diff --git a/tests/fuzz/fuzz_geo2.c b/tests/fuzz/fuzz_geo2.c -new file mode 100644 -index 000000000..ceee7ea6b ---- /dev/null -+++ b/tests/fuzz/fuzz_geo2.c -@@ -0,0 +1,69 @@ -+#include -+#include -+#include -+#include -+#include -+ -+#include "geos_c.h" -+ -+static int initialized = 0; -+FILE * flogOut; -+ -+void -+notice(const char *fmt, ...) { -+ va_list ap; -+ fprintf( flogOut, "NOTICE: "); -+ va_start (ap, fmt); -+ vfprintf( flogOut, fmt, ap); -+ va_end(ap); -+ fprintf( flogOut, "\n" ); -+} -+ -+void -+log_and_exit(const char *fmt, ...) { -+ va_list ap; -+ fprintf( flogOut, "ERROR: "); -+ va_start (ap, fmt); -+ vfprintf( flogOut, fmt, ap); -+ va_end(ap); -+ fprintf( flogOut, "\n" ); -+} -+ -+int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { -+ if (initialized == 0) { -+ flogOut = fopen("/dev/null", "wb"); -+ initGEOS(notice, log_and_exit); -+ initialized = 1; -+ } -+ size_t sep; -+ for (sep = 0; sep < Size; sep ++) { -+ if (Data[sep] == 0) { -+ break; -+ } -+ } -+ if (sep == Size) { -+ return 0; -+ } -+ GEOSGeometry *g1 = GEOSGeomFromWKT(Data); -+ -+ if (g1 != NULL) { -+ GEOSGeometry *g2 = GEOSGeomFromWKB_buf(Data+sep, Size-sep); -+ if (g2 != NULL) { -+ size_t usize; -+ GEOSGeometry *g3 = GEOSIntersection(g1, g2); -+ GEOSGeom_destroy(g3); -+ g3 = GEOSDifference(g1, g2); -+ GEOSGeom_destroy(g3); -+ g3 = GEOSUnion(g1, g2); -+ GEOSGeom_destroy(g3); -+ unsigned char* uptr = GEOSGeomToWKB_buf(g1, &usize); -+ free(uptr); -+ GEOSGeom_destroy(g2); -+ } -+ char * r = GEOSGeomToWKT(g1); -+ free(r); -+ GEOSGeom_destroy(g1); -+ } -+ return 0; -+} -+ diff --git a/projects/open5gs/build.sh b/projects/open5gs/build.sh index 38d9e4e4f96e..61f508b4f680 100644 --- a/projects/open5gs/build.sh +++ b/projects/open5gs/build.sh @@ -26,11 +26,13 @@ meson setup builddir --default-library=static -Dfuzzing=true -Dlib_fuzzing_engin ninja -C builddir -k 0 \ tests/fuzzing/gtp_message_fuzz \ tests/fuzzing/nas_message_fuzz \ - tests/fuzzing/ngap_message_fuzz + tests/fuzzing/ngap_message_fuzz \ + tests/fuzzing/s1ap_message_fuzz cp builddir/tests/fuzzing/gtp_message_fuzz $OUT/gtp_message_fuzz cp builddir/tests/fuzzing/nas_message_fuzz $OUT/nas_message_fuzz cp builddir/tests/fuzzing/ngap_message_fuzz $OUT/ngap_message_fuzz +cp builddir/tests/fuzzing/s1ap_message_fuzz $OUT/s1ap_message_fuzz mkdir -p $OUT/lib/ cp /lib/x86_64-linux-gnu/libtalloc.so* $OUT/lib/ diff --git a/projects/trust-dns/build.sh b/projects/trust-dns/build.sh index 680aec5a9bc1..6af69d6f8781 100755 --- a/projects/trust-dns/build.sh +++ b/projects/trust-dns/build.sh @@ -15,5 +15,5 @@ # ################################################################################ -cargo fuzz build -O +cargo fuzz build -O --debug-assertions cp fuzz/target/x86_64-unknown-linux-gnu/release/message $OUT/