diff --git a/projects/libarchive/Dockerfile b/projects/libarchive/Dockerfile index 99789fa0c..c41e51ca7 100644 --- a/projects/libarchive/Dockerfile +++ b/projects/libarchive/Dockerfile @@ -14,18 +14,14 @@ # ################################################################################ -# Using Ubuntu 16.04 because of breakage on Ubuntu 20.04. -# See https://github.com/google/oss-fuzz/issues/6291 for more details. -FROM gcr.io/oss-fuzz-base/base-builder:xenial -# Delete line above and uncomment line below to upgrade to 20.04. -# FROM gcr.io/oss-fuzz-base/base-builder +FROM gcr.io/oss-fuzz-base/base-builder -# Installing optional libraries can utilize more code path and/or improve -# performance (avoid calling external programs). RUN apt-get update && apt-get install -y make autoconf automake libtool pkg-config \ libbz2-dev liblzo2-dev liblzma-dev liblz4-dev libz-dev \ - libxml2-dev libssl-dev libacl1-dev libattr1-dev lrzip \ - liblz4-tool lzop zstd lcab genisoimage jlha-utils rar default-jdk + libssl-dev libacl1-dev libattr1-dev lrzip \ + liblz4-tool lzop zstd lcab genisoimage jlha-utils rar default-jdk RUN git clone --depth 1 https://github.com/libarchive/libarchive.git -WORKDIR libarchive +RUN git clone --depth 1 https://gitlab.gnome.org/GNOME/libxml2.git + COPY build.sh libarchive_fuzzer.cc $SRC/ +WORKDIR $SRC diff --git a/projects/libarchive/build.sh b/projects/libarchive/build.sh index 87587a57d..a46a44d2a 100755 --- a/projects/libarchive/build.sh +++ b/projects/libarchive/build.sh @@ -15,18 +15,35 @@ # ################################################################################ -# build the project -./build/autogen.sh -./configure -make -j$(nproc) all +# compile libxml2 from source so we can statically link +DEPS=/deps +mkdir ${DEPS} +cd $SRC/libxml2 +./autogen.sh \ + --without-debug \ + --without-ftp \ + --without-http \ + --without-legacy \ + --without-python +make -j$(nproc) +make install +cp .libs/libxml2.a ${DEPS}/ +cd $SRC/libarchive + +sed -i 's/-Wall//g' ./CMakeLists.txt +sed -i 's/-Werror//g' ./CMakeLists.txt + +mkdir build2 +cd build2 +cmake ../ +make # build seed cp $SRC/libarchive/contrib/oss-fuzz/corpus.zip\ - $OUT/libarchive_fuzzer_seed_corpus.zip + $OUT/libarchive_fuzzer_seed_corpus.zip # build fuzzer(s) -$CXX $CXXFLAGS -Ilibarchive \ +$CXX $CXXFLAGS -I../libarchive \ $SRC/libarchive_fuzzer.cc -o $OUT/libarchive_fuzzer \ - $LIB_FUZZING_ENGINE .libs/libarchive.a \ - -Wl,-Bstatic -lbz2 -llzo2 -lxml2 -llzma -lz -lcrypto -llz4 -licuuc \ - -licudata -Wl,-Bdynamic + $LIB_FUZZING_ENGINE ./libarchive/libarchive.a \ + -lcrypto -lacl -llzma -llz4 -lbz2 -lz ${DEPS}/libxml2.a