diff options
-rw-r--r-- | BUILD.gn | 32 | ||||
-rw-r--r-- | core/fxcodec/codec/ccodec_progressivedecoder.h | 17 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec.cpp | 31 | ||||
-rw-r--r-- | core/fxcodec/codec/fx_codec_progress.cpp | 16 | ||||
-rw-r--r-- | core/fxcodec/fx_codec.h | 56 | ||||
-rw-r--r-- | core/fxcodec/fx_codec_def.h | 2 | ||||
-rw-r--r-- | testing/libfuzzer/BUILD.gn | 32 | ||||
-rw-r--r-- | testing/libfuzzer/xfa_codec_fuzzer.h | 21 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 2 |
9 files changed, 144 insertions, 65 deletions
@@ -284,7 +284,9 @@ jumbo_static_library("image_diff") { "testing/image_diff/image_diff_png.h", ] configs += [ ":pdfium_core_config" ] - deps = [ "third_party:png" ] + deps = [ + "third_party:png", + ] } # Targets below this are only visible within this file (and to the @@ -786,17 +788,21 @@ jumbo_static_library("fxcodec") { "core/fxcodec/bmp/fx_bmp.h", "core/fxcodec/codec/ccodec_bmpmodule.cpp", "core/fxcodec/codec/ccodec_bmpmodule.h", - "core/fxcodec/codec/ccodec_gifmodule.cpp", - "core/fxcodec/codec/ccodec_gifmodule.h", "core/fxcodec/codec/ccodec_progressivedecoder.h", "core/fxcodec/codec/fx_codec_progress.cpp", - "core/fxcodec/gif/cfx_gif.cpp", - "core/fxcodec/gif/cfx_gif.h", - "core/fxcodec/gif/cfx_gifcontext.cpp", - "core/fxcodec/gif/cfx_gifcontext.h", - "core/fxcodec/gif/cfx_lzwdecompressor.cpp", - "core/fxcodec/gif/cfx_lzwdecompressor.h", ] + if (pdf_enable_xfa_gif) { + sources += [ + "core/fxcodec/codec/ccodec_gifmodule.cpp", + "core/fxcodec/codec/ccodec_gifmodule.h", + "core/fxcodec/gif/cfx_gif.cpp", + "core/fxcodec/gif/cfx_gif.h", + "core/fxcodec/gif/cfx_gifcontext.cpp", + "core/fxcodec/gif/cfx_gifcontext.h", + "core/fxcodec/gif/cfx_lzwdecompressor.cpp", + "core/fxcodec/gif/cfx_lzwdecompressor.h", + ] + } if (pdf_enable_xfa_png) { sources += [ "core/fxcodec/codec/ccodec_pngmodule.cpp", @@ -2921,8 +2927,6 @@ test("pdfium_unittests") { include_dirs = [] if (pdf_enable_xfa) { sources += [ - "core/fxcodec/gif/cfx_gifcontext_unittest.cpp", - "core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp", "core/fxcrt/css/cfx_cssdeclaration_unittest.cpp", "core/fxcrt/css/cfx_cssstylesheet_unittest.cpp", "core/fxcrt/css/cfx_cssvaluelistparser_unittest.cpp", @@ -2949,6 +2953,12 @@ test("pdfium_unittests") { "xfa/fxfa/parser/cxfa_xmllocale_unittest.cpp", "xfa/fxfa/parser/xfa_utils_unittest.cpp", ] + if (pdf_enable_xfa_gif) { + sources += [ + "core/fxcodec/gif/cfx_gifcontext_unittest.cpp", + "core/fxcodec/gif/cfx_lzwdecompressor_unittest.cpp", + ] + } } if (pdf_use_skia || pdf_use_skia_paths) { sources += [ "core/fxge/skia/fx_skia_device_unittest.cpp" ] diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h index 476a7c1b4a..07716a80ae 100644 --- a/core/fxcodec/codec/ccodec_progressivedecoder.h +++ b/core/fxcodec/codec/ccodec_progressivedecoder.h @@ -12,7 +12,6 @@ #include <vector> #include "core/fxcodec/codec/ccodec_bmpmodule.h" -#include "core/fxcodec/codec/ccodec_gifmodule.h" #include "core/fxcodec/codec/ccodec_jpegmodule.h" #include "core/fxcodec/fx_codec_def.h" #include "core/fxcrt/fx_system.h" @@ -21,6 +20,10 @@ #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_dib.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 @@ -36,7 +39,9 @@ class IFX_SeekableReadStream; class CCodec_Dummy {}; // Placeholder to work around C++ syntax issues class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, +#ifdef PDF_ENABLE_XFA_GIF public CCodec_GifModule::Delegate, +#endif // PDF_ENABLE_XFA_GIF #ifdef PDF_ENABLE_XFA_PNG public CCodec_PngModule::Delegate, #endif // PDF_ENABLE_XFA_PNG @@ -146,6 +151,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, void PngFillScanlineBufCompleted(int pass, int line) override; #endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_GIF // CCodec_GifModule::Delegate void GifRecordCurrentPosition(uint32_t& cur_pos) override; bool GifInputRecordPositionBuf(uint32_t rcd_pos, @@ -158,6 +164,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, int32_t disposal_method, bool interlace) override; void GifReadScanline(int32_t row_num, uint8_t* row_buf) override; +#endif // PDF_ENABLE_XFA_GIF // CCodec_BmpModule::Delegate bool BmpInputImagePositionBuf(uint32_t rcd_pos) override; @@ -171,6 +178,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, FXCODEC_STATUS BmpStartDecode(const RetainPtr<CFX_DIBitmap>& pDIBitmap); FXCODEC_STATUS BmpContinueDecode(); +#ifdef PDF_ENABLE_XFA_GIF bool GifReadMoreData(CCodec_GifModule* pGifModule, FXCODEC_STATUS& err_status); bool GifDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size); @@ -179,6 +187,7 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, void GifDoubleLineResampleVert(const RetainPtr<CFX_DIBitmap>& pDeviceBitmap, double scale_y, int dest_row); +#endif // PDF_ENABLE_XFA_GIF bool JpegReadMoreData(CCodec_JpegModule* pJpegModule, FXCODEC_STATUS& err_status); @@ -229,7 +238,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, #ifdef PDF_ENABLE_XFA_PNG std::unique_ptr<CCodec_PngModule::Context> m_pPngContext; #endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_GIF std::unique_ptr<CCodec_GifModule::Context> m_pGifContext; +#endif // PDF_ENABLE_XFA_GIF std::unique_ptr<CCodec_BmpModule::Context> m_pBmpContext; #ifdef PDF_ENABLE_XFA_TIFF std::unique_ptr<CCodec_TiffModule::Context> m_pTiffContext; @@ -260,14 +271,16 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate, int m_SrcPassNumber; size_t m_FrameNumber; size_t m_FrameCur; +#ifdef PDF_ENABLE_XFA_GIF int m_GifBgIndex; CFX_GifPalette* m_pGifPalette; int32_t m_GifPltNumber; int m_GifTransIndex; FX_RECT m_GifFrameRect; + bool m_InvalidateGifBuffer; +#endif // PDF_ENABLE_XFA_GIF bool m_BmpIsTopBottom; FXCODEC_STATUS m_status; - bool m_InvalidateGifBuffer; }; #endif // CORE_FXCODEC_CODEC_CCODEC_PROGRESSIVEDECODER_H_ diff --git a/core/fxcodec/codec/fx_codec.cpp b/core/fxcodec/codec/fx_codec.cpp index 22e4bc50cc..e58da052aa 100644 --- a/core/fxcodec/codec/fx_codec.cpp +++ b/core/fxcodec/codec/fx_codec.cpp @@ -26,13 +26,6 @@ #include "third_party/base/logging.h" #include "third_party/base/ptr_util.h" -#ifdef PDF_ENABLE_XFA -#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_tiffmodule.h" -#endif // PDF_ENABLE_XFA - namespace { const uint8_t g_CMYK[81 * 81 * 3] = { @@ -1364,25 +1357,6 @@ CCodec_ModuleMgr::CCodec_ModuleMgr() CCodec_ModuleMgr::~CCodec_ModuleMgr() {} -#ifdef PDF_ENABLE_XFA -void CCodec_ModuleMgr::SetBmpModule(std::unique_ptr<CCodec_BmpModule> module) { - m_pBmpModule = std::move(module); -} - -void CCodec_ModuleMgr::SetGifModule(std::unique_ptr<CCodec_GifModule> module) { - m_pGifModule = std::move(module); -} - -void CCodec_ModuleMgr::SetPngModule(std::unique_ptr<CCodec_PngModule> module) { - m_pPngModule = std::move(module); -} - -void CCodec_ModuleMgr::SetTiffModule( - std::unique_ptr<CCodec_TiffModule> module) { - m_pTiffModule = std::move(module); -} -#endif // PDF_ENABLE_XFA - bool CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf, uint32_t src_size, uint8_t** dest_buf, @@ -1540,11 +1514,14 @@ CFX_DIBAttribute::CFX_DIBAttribute() m_nYDPI(-1), m_fAspectRatio(-1.0f), m_wDPIUnit(0), +#ifdef PDF_ENABLE_XFA_GIF m_nGifLeft(0), m_nGifTop(0), m_pGifLocalPalette(nullptr), m_nGifLocalPalNum(0), - m_nBmpCompressType(0) {} +#endif // PDF_ENABLE_XFA_GIF + m_nBmpCompressType(0) { +} CFX_DIBAttribute::~CFX_DIBAttribute() { for (const auto& pair : m_Exif) diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp index bfd60acd0e..1d6bc708db 100644 --- a/core/fxcodec/codec/fx_codec_progress.cpp +++ b/core/fxcodec/codec/fx_codec_progress.cpp @@ -275,13 +275,15 @@ CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder( m_FrameNumber = 0; m_FrameCur = 0; m_SrcPaletteNumber = 0; +#ifdef PDF_ENABLE_XFA_GIF m_GifPltNumber = 0; m_GifBgIndex = 0; m_pGifPalette = nullptr; m_GifTransIndex = -1; m_GifFrameRect = FX_RECT(0, 0, 0, 0); - m_BmpIsTopBottom = false; m_InvalidateGifBuffer = true; +#endif // PDF_ENABLE_XFA_GIF + m_BmpIsTopBottom = false; } CCodec_ProgressiveDecoder::~CCodec_ProgressiveDecoder() { @@ -450,6 +452,7 @@ void CCodec_ProgressiveDecoder::PngFillScanlineBufCompleted(int pass, } #endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_GIF void CCodec_ProgressiveDecoder::GifRecordCurrentPosition(uint32_t& cur_pos) { uint32_t remain_size = m_pCodecMgr->GetGifModule()->GetAvailInput(m_pGifContext.get()); @@ -608,6 +611,7 @@ void CCodec_ProgressiveDecoder::GifReadScanline(int32_t row_num, if (bLastPass) GifDoubleLineResampleVert(pDIBitmap, scale_y, dest_row); } +#endif // PDF_ENABLE_XFA_GIF bool CCodec_ProgressiveDecoder::BmpInputImagePositionBuf(uint32_t rcd_pos) { m_offSet = rcd_pos; @@ -923,6 +927,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::BmpContinueDecode() { } } +#ifdef PDF_ENABLE_XFA_GIF bool CCodec_ProgressiveDecoder::GifReadMoreData(CCodec_GifModule* pGifModule, FXCODEC_STATUS& err_status) { if (static_cast<uint32_t>(m_pFile->GetSize()) <= m_offSet) @@ -1151,6 +1156,7 @@ void CCodec_ProgressiveDecoder::GifDoubleLineResampleVert( GifDoubleLineResampleVert(pDeviceBitmap, scale_y, dest_row + (int)scale_y); } } +#endif // PDF_ENABLE_XFA_GIF bool CCodec_ProgressiveDecoder::JpegReadMoreData(CCodec_JpegModule* pJpegModule, FXCODEC_STATUS& err_status) { @@ -1735,8 +1741,10 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType, case FXCODEC_IMAGE_PNG: return PngDetectImageType(pAttribute, size); #endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_GIF: return GifDetectImageType(pAttribute, size); +#endif // PDF_ENABLE_XFA_GIF #ifdef PDF_ENABLE_XFA_TIFF case FXCODEC_IMAGE_TIFF: return TiffDetectImageType(pAttribute, size); @@ -2309,6 +2317,7 @@ std::pair<FXCODEC_STATUS, size_t> CCodec_ProgressiveDecoder::GetFrames() { m_FrameNumber = 1; m_status = FXCODEC_STATUS_DECODE_READY; return {m_status, 1}; +#ifdef PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_GIF: { CCodec_GifModule* pGifModule = m_pCodecMgr->GetGifModule(); if (!pGifModule) { @@ -2336,6 +2345,7 @@ std::pair<FXCODEC_STATUS, size_t> CCodec_ProgressiveDecoder::GetFrames() { return {m_status, 0}; } } +#endif // PDF_ENABLE_XFA_GIF default: return {FXCODEC_STATUS_ERROR, 0}; } @@ -2401,8 +2411,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode( case FXCODEC_IMAGE_PNG: return PngStartDecode(pDIBitmap); #endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_GIF: return GifStartDecode(pDIBitmap); +#endif // PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_BMP: return BmpStartDecode(pDIBitmap); #ifdef PDF_ENABLE_XFA_TIFF @@ -2426,8 +2438,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() { case FXCODEC_IMAGE_PNG: return PngContinueDecode(); #endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_GIF: return GifContinueDecode(); +#endif // PDF_ENABLE_XFA_GIF case FXCODEC_IMAGE_BMP: return BmpContinueDecode(); #ifdef PDF_ENABLE_XFA_TIFF diff --git a/core/fxcodec/fx_codec.h b/core/fxcodec/fx_codec.h index 5ed29d4da5..b5e8d8ad39 100644 --- a/core/fxcodec/fx_codec.h +++ b/core/fxcodec/fx_codec.h @@ -18,6 +18,22 @@ #include "core/fxcrt/fx_safe_types.h" #include "core/fxcrt/fx_string.h" +#ifdef PDF_ENABLE_XFA +#include "core/fxcodec/codec/ccodec_bmpmodule.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 +#endif // PDF_ENABLE_XFA + class CCodec_BasicModule; class CCodec_FaxModule; class CCodec_FlateModule; @@ -31,11 +47,7 @@ class CPDF_ColorSpace; class CPDF_StreamAcc; #ifdef PDF_ENABLE_XFA -class CCodec_BmpModule; -class CCodec_GifModule; -class CCodec_PngModule; class CCodec_ProgressiveDecoder; -class CCodec_TiffModule; class CFX_DIBAttribute { public: @@ -46,10 +58,12 @@ class CFX_DIBAttribute { int32_t m_nYDPI; float m_fAspectRatio; uint16_t m_wDPIUnit; +#ifdef PDF_ENABLE_XFA_GIF int32_t m_nGifLeft; int32_t m_nGifTop; uint32_t* m_pGifLocalPalette; uint32_t m_nGifLocalPalNum; +#endif // PDF_ENABLE_XFA_GIF int32_t m_nBmpCompressType; std::map<uint32_t, void*> m_Exif; }; @@ -70,14 +84,31 @@ class CCodec_ModuleMgr { #ifdef PDF_ENABLE_XFA std::unique_ptr<CCodec_ProgressiveDecoder> CreateProgressiveDecoder(); - void SetBmpModule(std::unique_ptr<CCodec_BmpModule> module); - void SetGifModule(std::unique_ptr<CCodec_GifModule> module); - void SetPngModule(std::unique_ptr<CCodec_PngModule> module); - void SetTiffModule(std::unique_ptr<CCodec_TiffModule> module); CCodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } + void SetBmpModule(std::unique_ptr<CCodec_BmpModule> module) { + m_pBmpModule = std::move(module); + } + +#ifdef PDF_ENABLE_XFA_GIF CCodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } + void SetGifModule(std::unique_ptr<CCodec_GifModule> module) { + m_pGifModule = std::move(module); + } +#endif // PDF_ENABLE_XFA_GIF + +#ifdef PDF_ENABLE_XFA_PNG CCodec_PngModule* GetPngModule() const { return m_pPngModule.get(); } + void SetPngModule(std::unique_ptr<CCodec_PngModule> module) { + m_pPngModule = std::move(module); + } +#endif // PDF_ENABLE_XFA_PNG + +#ifdef PDF_ENABLE_XFA_TIFF CCodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); } + void SetTiffModule(std::unique_ptr<CCodec_TiffModule> module) { + m_pTiffModule = std::move(module); + } +#endif // PDF_ENABLE_XFA_TIFF #endif // PDF_ENABLE_XFA protected: @@ -90,9 +121,18 @@ class CCodec_ModuleMgr { #ifdef PDF_ENABLE_XFA std::unique_ptr<CCodec_BmpModule> m_pBmpModule; + +#ifdef PDF_ENABLE_XFA_GIF std::unique_ptr<CCodec_GifModule> m_pGifModule; +#endif // PDF_ENABLE_XFA_GIF + +#ifdef PDF_ENABLE_XFA_PNG std::unique_ptr<CCodec_PngModule> m_pPngModule; +#endif // PDF_ENABLE_XFA_PNG + +#ifdef PDF_ENABLE_XFA_TIFF std::unique_ptr<CCodec_TiffModule> m_pTiffModule; +#endif // PDF_ENABLE_XFA_TIFF #endif // PDF_ENABLE_XFA std::unique_ptr<CCodec_FlateModule> m_pFlateModule; diff --git a/core/fxcodec/fx_codec_def.h b/core/fxcodec/fx_codec_def.h index b7944ee1c1..f7d6916aa5 100644 --- a/core/fxcodec/fx_codec_def.h +++ b/core/fxcodec/fx_codec_def.h @@ -31,7 +31,9 @@ enum FXCODEC_IMAGE_TYPE { #ifdef PDF_ENABLE_XFA_PNG FXCODEC_IMAGE_PNG, #endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_GIF FXCODEC_IMAGE_GIF, +#endif // PDF_ENABLE_XFA_GIF #ifdef PDF_ENABLE_XFA_TIFF FXCODEC_IMAGE_TIFF, #endif // PDF_ENABLE_XFA_TIFF 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(); diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 7e479b1858..f178bd92a9 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -169,8 +169,10 @@ FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType) { if (wsContentType == L"image/png") return FXCODEC_IMAGE_PNG; #endif // PDF_ENABLE_XFA_PNG +#ifdef PDF_ENABLE_XFA_GIF if (wsContentType == L"image/gif") return FXCODEC_IMAGE_GIF; +#endif // PDF_ENABLE_XFA_GIF if (wsContentType == L"image/bmp") return FXCODEC_IMAGE_BMP; #ifdef PDF_ENABLE_XFA_TIFF |