aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects/poppler
diff options
context:
space:
mode:
authorGravatar Jonathan Rudenberg <jonathan@titanous.com>2018-05-21 15:22:29 -0400
committerGravatar Abhishek Arya <inferno@chromium.org>2018-05-21 12:22:29 -0700
commit6836cc64e072237317d53588f5fff7714fded455 (patch)
tree0b78250e81a0ba3862c4bd70e09590ed633a5eb5 /projects/poppler
parentcaddf9a8af0758b9821f6c350b19ecb22e50c57e (diff)
[poppler] Add poppler (#1431)
* [poppler] Add poppler * cleanup * remove empty options
Diffstat (limited to 'projects/poppler')
-rw-r--r--projects/poppler/Dockerfile28
-rwxr-xr-xprojects/poppler/build.sh64
-rw-r--r--projects/poppler/pdf_fuzzer.cc48
-rw-r--r--projects/poppler/project.yaml8
4 files changed, 148 insertions, 0 deletions
diff --git a/projects/poppler/Dockerfile b/projects/poppler/Dockerfile
new file mode 100644
index 00000000..98b77ddf
--- /dev/null
+++ b/projects/poppler/Dockerfile
@@ -0,0 +1,28 @@
+# Copyright 2018 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 jonathan@titanous.com
+RUN apt-get update && apt-get install -y make autoconf automake libtool pkg-config cmake
+RUN git clone --depth 1 https://anongit.freedesktop.org/git/poppler/poppler.git
+RUN git clone --depth 1 git://git.sv.nongnu.org/freetype/freetype2.git
+RUN git clone --depth 1 https://github.com/mozilla/pdf.js pdf.js && \
+ zip -q $SRC/pdf_fuzzer_seed_corpus.zip pdf.js/test/pdfs/*.pdf && \
+ rm -rf pdf.js
+ADD https://raw.githubusercontent.com/rc0r/afl-fuzz/master/dictionaries/pdf.dict $SRC/pdf_fuzzer.dict
+WORKDIR $SRC
+COPY *.cc poppler/fuzz/
+COPY build.sh $SRC/
diff --git a/projects/poppler/build.sh b/projects/poppler/build.sh
new file mode 100755
index 00000000..73059bf6
--- /dev/null
+++ b/projects/poppler/build.sh
@@ -0,0 +1,64 @@
+#!/bin/bash -eu
+# Copyright 2018 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.
+#
+################################################################################
+
+pushd $SRC/freetype2
+./autogen.sh
+./configure --prefix="$WORK" --disable-shared PKG_CONFIG_PATH="$WORK/lib/pkgconfig"
+make -j$(nproc)
+make install
+
+mkdir -p $WORK/poppler
+pushd $WORK/poppler
+cmake $SRC/poppler \
+ -DCMAKE_BUILD_TYPE=debug \
+ -DBUILD_SHARED_LIBS=OFF \
+ -DFONT_CONFIGURATION=generic \
+ -DENABLE_DCTDECODER=none \
+ -DENABLE_LIBOPENJPEG=none \
+ -DENABLE_CMS=none \
+ -DENABLE_LIBPNG=OFF \
+ -DENABLE_ZLIB=OFF \
+ -DENABLE_LIBTIFF=OFF \
+ -DENABLE_LIBJPEG=OFF \
+ -DENABLE_GLIB=OFF \
+ -DENABLE_LIBCURL=OFF \
+ -DENABLE_QT5=OFF \
+ -DENABLE_UTILS=OFF \
+ -DWITH_Cairo=OFF \
+ -DWITH_NSS3=OFF \
+ -DFREETYPE_INCLUDE_DIRS=$WORK/include/freetype2 \
+ -DFREETYPE_LIBRARY=$WORK/lib
+make -j$(nproc) poppler poppler-cpp
+
+fuzz_target=pdf_fuzzer
+
+pushd $SRC/poppler
+$CXX $CXXFLAGS -std=c++11 -Icpp \
+ fuzz/pdf_fuzzer.cc -o $OUT/$fuzz_target \
+ -lFuzzingEngine $WORK/poppler/cpp/libpoppler-cpp.a $WORK/poppler/libpoppler.a $WORK/lib/libfreetype.a
+
+mv $SRC/{*.zip,*.dict} $OUT
+
+if [ ! -f "${OUT}/${fuzz_target}_seed_corpus.zip" ]; then
+ echo "missing seed corpus"
+ exit 1
+fi
+
+if [ ! -f "${OUT}/${fuzz_target}.dict" ]; then
+ echo "missing dictionary"
+ exit 1
+fi
diff --git a/projects/poppler/pdf_fuzzer.cc b/projects/poppler/pdf_fuzzer.cc
new file mode 100644
index 00000000..93ba5d14
--- /dev/null
+++ b/projects/poppler/pdf_fuzzer.cc
@@ -0,0 +1,48 @@
+/*
+# Copyright 2018 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 <cstdint>
+
+#include <poppler-global.h>
+#include <poppler-document.h>
+#include <poppler-page.h>
+#include <poppler-page-renderer.h>
+
+static void nop_func(const std::string& msg, void*) {};
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ poppler::set_debug_error_function(nop_func, nullptr);
+
+ poppler::document *doc = poppler::document::load_from_raw_data((const char *)data, size);
+ if (!doc) {
+ return 0;
+ }
+
+ poppler::page_renderer r;
+ for (int i = 0; i < doc->pages(); i++) {
+ poppler::page *p = doc->create_page(i);
+ if (!p) {
+ continue;
+ }
+ r.render_page(p);
+ delete p;
+ }
+
+ delete doc;
+ return 0;
+}
diff --git a/projects/poppler/project.yaml b/projects/poppler/project.yaml
new file mode 100644
index 00000000..7f779151
--- /dev/null
+++ b/projects/poppler/project.yaml
@@ -0,0 +1,8 @@
+homepage: https://poppler.freedesktop.org/
+primary_contact: tsdgeos@gmail.com
+sanitizers:
+ - address
+ - memory
+ - undefined
+auto_ccs:
+ - jonathan@titanous.com