-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [poppler] Add poppler * cleanup * remove empty options
- Loading branch information
1 parent
caddf9a
commit 6836cc6
Showing
4 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
homepage: https://poppler.freedesktop.org/ | ||
primary_contact: tsdgeos@gmail.com | ||
sanitizers: | ||
- address | ||
- memory | ||
- undefined | ||
auto_ccs: | ||
- jonathan@titanous.com |