diff --git a/projects/xpdf/Dockerfile b/projects/xpdf/Dockerfile new file mode 100755 index 000000000..4413a4933 --- /dev/null +++ b/projects/xpdf/Dockerfile @@ -0,0 +1,24 @@ +# Copyright 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder +MAINTAINER david@adalogics.com +RUN apt-get update && apt-get install -y make wget cmake libqt4-dev +RUN wget https://xpdfreader-dl.s3.amazonaws.com/xpdf-4.02.tar.gz + +WORKDIR $SRC +COPY fuzz_*.cc $SRC/ +COPY build.sh $SRC/ diff --git a/projects/xpdf/build.sh b/projects/xpdf/build.sh new file mode 100755 index 000000000..4dfc18979 --- /dev/null +++ b/projects/xpdf/build.sh @@ -0,0 +1,35 @@ +#!/bin/bash -eu +# Copyright 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +# Unpack the file +tar -zxvf xpdf-4.02.tar.gz + +# Now make the build directory +cd xpdf-4.02 + +# Make minor change in the CMakeFiles file. +sed -i 's/#--- object files needed by XpdfWidget/add_library(testXpdfStatic STATIC $)\n#--- object files needed by XpdfWidget/' ./xpdf/CMakeLists.txt + +# Build the project +mkdir build && cd build +export LD=$CXX +cmake ../ -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" +make -i || true + +# Build fuzzers +cp ../../fuzz_zxdoc.cc . +$CXX fuzz_zxdoc.cc -o $OUT/fuzz_zxdoc ./xpdf/libtestXpdfStatic.a ./fofi/libfofi.a ./goo/libgoo.a -I../ -I../goo -I../fofi -I. -I../xpdf $CXXFLAGS $LIB_FUZZING_ENGINE diff --git a/projects/xpdf/fuzz_zxdoc.cc b/projects/xpdf/fuzz_zxdoc.cc new file mode 100644 index 000000000..54a551492 --- /dev/null +++ b/projects/xpdf/fuzz_zxdoc.cc @@ -0,0 +1,34 @@ +/* Copyright 2020 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +#include +#include +#include +#include "Zoox.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + char *ss = (char*)malloc(size+1); + memcpy(ss, data, size); + ss[size] = '\0'; + + ZxDoc Z1; + ZxDoc *new_doc = Z1.loadMem(ss, size); + if (new_doc != NULL) + delete new_doc; + + free(ss); + + return 0; +} diff --git a/projects/xpdf/project.yaml b/projects/xpdf/project.yaml new file mode 100755 index 000000000..64eb5e504 --- /dev/null +++ b/projects/xpdf/project.yaml @@ -0,0 +1,5 @@ +homepage: "https://www.xpdfreader.com/" +primary_contact: "xpdf@xpdfreader.com" +language: c++ +auto_ccs : + - "david@adalogics.com"