From 607f3cd63a314cd3a6c219b19cce31805b66cd6d Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 9 May 2018 21:06:22 +0000 Subject: Do not build GIF when codec is disabled Currently all of the GIF related code is being built when support for the codec is disabled, it just isn't being utilized. Depending on the settings being used, this unneeded code may or may not get stripped during linking. This CL explicitly turns off building the GIF codec code if support for GIF is turned off. This also catches a few missed cases from previous CLs. BUG=pdfium:1080 Change-Id: Ie7fe2d894d2ae2f8f36ae05e0ff256f2ce6ef8d4 Reviewed-on: https://pdfium-review.googlesource.com/32330 Reviewed-by: Tom Sepez Commit-Queue: Ryan Harrison --- testing/libfuzzer/BUILD.gn | 32 +++++++++++++++++++------------- testing/libfuzzer/xfa_codec_fuzzer.h | 21 ++++++++++++++++++--- 2 files changed, 37 insertions(+), 16 deletions(-) (limited to 'testing') diff --git a/testing/libfuzzer/BUILD.gn b/testing/libfuzzer/BUILD.gn index 5a050a2237..1d17d3d4e7 100644 --- a/testing/libfuzzer/BUILD.gn +++ b/testing/libfuzzer/BUILD.gn @@ -40,13 +40,17 @@ group("libfuzzer") { deps += [ ":pdf_cfx_barcode_fuzzer", ":pdf_codec_bmp_fuzzer", - ":pdf_codec_gif_fuzzer", ":pdf_codec_jpeg_fuzzer", ":pdf_css_fuzzer", ":pdf_fm2js_fuzzer", ":pdf_formcalc_fuzzer", - ":pdf_lzw_fuzzer", ] + if (pdf_enable_xfa_gif) { + deps += [ + ":pdf_codec_gif_fuzzer", + ":pdf_lzw_fuzzer", + ] + } if (pdf_enable_xfa_png) { deps += [ ":pdf_codec_png_fuzzer" ] } @@ -88,11 +92,19 @@ if (pdf_enable_xfa) { ] } - pdfium_fuzzer("pdf_codec_gif_fuzzer") { - sources = [ - "pdf_codec_gif_fuzzer.cc", - "xfa_codec_fuzzer.h", - ] + if (pdf_enable_xfa_gif) { + pdfium_fuzzer("pdf_codec_gif_fuzzer") { + sources = [ + "pdf_codec_gif_fuzzer.cc", + "xfa_codec_fuzzer.h", + ] + } + + pdfium_fuzzer("pdf_lzw_fuzzer") { + sources = [ + "pdf_lzw_fuzzer.cc", + ] + } } pdfium_fuzzer("pdf_codec_jpeg_fuzzer") { @@ -137,12 +149,6 @@ if (pdf_enable_xfa) { "pdf_formcalc_fuzzer.cc", ] } - - pdfium_fuzzer("pdf_lzw_fuzzer") { - sources = [ - "pdf_lzw_fuzzer.cc", - ] - } } pdfium_fuzzer("pdf_cmap_fuzzer") { diff --git a/testing/libfuzzer/xfa_codec_fuzzer.h b/testing/libfuzzer/xfa_codec_fuzzer.h index b1d888f380..483177e232 100644 --- a/testing/libfuzzer/xfa_codec_fuzzer.h +++ b/testing/libfuzzer/xfa_codec_fuzzer.h @@ -8,15 +8,24 @@ #include #include "core/fxcodec/codec/ccodec_bmpmodule.h" -#include "core/fxcodec/codec/ccodec_gifmodule.h" -#include "core/fxcodec/codec/ccodec_pngmodule.h" #include "core/fxcodec/codec/ccodec_progressivedecoder.h" -#include "core/fxcodec/codec/ccodec_tiffmodule.h" #include "core/fxcodec/fx_codec.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "testing/fx_string_testhelpers.h" #include "third_party/base/ptr_util.h" +#ifdef PDF_ENABLE_XFA_GIF +#include "core/fxcodec/codec/ccodec_gifmodule.h" +#endif // PDF_ENABLE_XFA_GIF + +#ifdef PDF_ENABLE_XFA_PNG +#include "core/fxcodec/codec/ccodec_pngmodule.h" +#endif // PDF_ENABLE_XFA_PNG + +#ifdef PDF_ENABLE_XFA_TIFF +#include "core/fxcodec/codec/ccodec_tiffmodule.h" +#endif // PDF_ENABLE_XFA_TIFF + // Support up to 64 MB. This prevents trivial OOM when MSAN is on and // time outs. const int kXFACodecFuzzerPixelLimit = 64000000; @@ -26,9 +35,15 @@ class XFACodecFuzzer { static int Fuzz(const uint8_t* data, size_t size, FXCODEC_IMAGE_TYPE type) { auto mgr = pdfium::MakeUnique(); mgr->SetBmpModule(pdfium::MakeUnique()); +#ifdef PDF_ENABLE_XFA_GIF mgr->SetGifModule(pdfium::MakeUnique()); +#endif // PDF_ENABLE_XFA_GIF +#ifdef PDF_ENABLE_XFA_PNG mgr->SetPngModule(pdfium::MakeUnique()); +#endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_TIFF mgr->SetTiffModule(pdfium::MakeUnique()); +#endif // PDF_ENABLE_XFA_TIFF std::unique_ptr decoder = mgr->CreateProgressiveDecoder(); -- cgit v1.2.3