summaryrefslogtreecommitdiff
path: root/testing/libfuzzer
diff options
context:
space:
mode:
Diffstat (limited to 'testing/libfuzzer')
-rw-r--r--testing/libfuzzer/BUILD.gn32
-rw-r--r--testing/libfuzzer/xfa_codec_fuzzer.h21
2 files changed, 37 insertions, 16 deletions
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 <memory>
#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<CCodec_ModuleMgr>();
mgr->SetBmpModule(pdfium::MakeUnique<CCodec_BmpModule>());
+#ifdef PDF_ENABLE_XFA_GIF
mgr->SetGifModule(pdfium::MakeUnique<CCodec_GifModule>());
+#endif // PDF_ENABLE_XFA_GIF
+#ifdef PDF_ENABLE_XFA_PNG
mgr->SetPngModule(pdfium::MakeUnique<CCodec_PngModule>());
+#endif // PDF_ENABLE_XFA_PNG
+#ifdef PDF_ENABLE_XFA_TIFF
mgr->SetTiffModule(pdfium::MakeUnique<CCodec_TiffModule>());
+#endif // PDF_ENABLE_XFA_TIFF
std::unique_ptr<CCodec_ProgressiveDecoder> decoder =
mgr->CreateProgressiveDecoder();