summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn14
-rw-r--r--core/fxcodec/codec/ccodec_progressivedecoder.h16
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp35
-rw-r--r--core/fxcodec/fx_codec_def.h4
-rw-r--r--testing/libfuzzer/BUILD.gn16
-rw-r--r--testing/libfuzzer/pdf_codec_tiff_fuzzer.cc2
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp5
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp4
8 files changed, 64 insertions, 32 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 874a8f7d81..c6663ec8f3 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -794,8 +794,6 @@ jumbo_static_library("fxcodec") {
"core/fxcodec/codec/ccodec_pngmodule.cpp",
"core/fxcodec/codec/ccodec_pngmodule.h",
"core/fxcodec/codec/ccodec_progressivedecoder.h",
- "core/fxcodec/codec/ccodec_tiffmodule.cpp",
- "core/fxcodec/codec/ccodec_tiffmodule.h",
"core/fxcodec/codec/fx_codec_progress.cpp",
"core/fxcodec/gif/cfx_gif.cpp",
"core/fxcodec/gif/cfx_gif.h",
@@ -804,10 +802,14 @@ jumbo_static_library("fxcodec") {
"core/fxcodec/gif/cfx_lzwdecompressor.cpp",
"core/fxcodec/gif/cfx_lzwdecompressor.h",
]
- deps += [
- "third_party:fx_tiff",
- "third_party:png",
- ]
+ deps += [ "third_party:png" ]
+ if (pdf_enable_xfa_tiff) {
+ sources += [
+ "core/fxcodec/codec/ccodec_tiffmodule.cpp",
+ "core/fxcodec/codec/ccodec_tiffmodule.h",
+ ]
+ deps += [ "third_party:fx_tiff" ]
+ }
}
if (is_posix || is_fuchsia) {
# core/fxcodec/fx_libopenjpeg/src/fx_mct.c does an pointer-to-int
diff --git a/core/fxcodec/codec/ccodec_progressivedecoder.h b/core/fxcodec/codec/ccodec_progressivedecoder.h
index a14ec0db29..9a0136c872 100644
--- a/core/fxcodec/codec/ccodec_progressivedecoder.h
+++ b/core/fxcodec/codec/ccodec_progressivedecoder.h
@@ -15,13 +15,17 @@
#include "core/fxcodec/codec/ccodec_gifmodule.h"
#include "core/fxcodec/codec/ccodec_jpegmodule.h"
#include "core/fxcodec/codec/ccodec_pngmodule.h"
-#include "core/fxcodec/codec/ccodec_tiffmodule.h"
#include "core/fxcodec/fx_codec_def.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxcrt/unowned_ptr.h"
+#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_dib.h"
+#ifdef PDF_ENABLE_XFA_TIFF
+#include "core/fxcodec/codec/ccodec_tiffmodule.h"
+#endif // PDF_ENABLE_XFA_TIFF
+
class CCodec_ModuleMgr;
class CFX_DIBAttribute;
class IFX_SeekableReadStream;
@@ -167,7 +171,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
bool JpegDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
bool PngDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
bool GifDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
- bool TifDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
+#ifdef PDF_ENABLE_XFA_TIFF
+ bool TiffDetectImageType(CFX_DIBAttribute* pAttribute, uint32_t size);
+#endif // PDF_ENABLE_XFA_TIFF
void GetDownScale(int& down_scale);
void GetTransMethod(FXDIB_Format dest_format, FXCodec_Format src_format);
@@ -199,7 +205,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
FXCODEC_STATUS PngContinueDecode();
FXCODEC_STATUS GifContinueDecode();
FXCODEC_STATUS BmpContinueDecode();
- FXCODEC_STATUS TifContinueDecode();
+#ifdef PDF_ENABLE_XFA_TIFF
+ FXCODEC_STATUS TiffContinueDecode();
+#endif // PDF_ENABLE_XFA_TIFF
RetainPtr<IFX_SeekableReadStream> m_pFile;
RetainPtr<CFX_DIBitmap> m_pDeviceBitmap;
@@ -208,7 +216,9 @@ class CCodec_ProgressiveDecoder : public CCodec_BmpModule::Delegate,
std::unique_ptr<CCodec_PngModule::Context> m_pPngContext;
std::unique_ptr<CCodec_GifModule::Context> m_pGifContext;
std::unique_ptr<CCodec_BmpModule::Context> m_pBmpContext;
+#ifdef PDF_ENABLE_XFA_TIFF
std::unique_ptr<CCodec_TiffModule::Context> m_pTiffContext;
+#endif // PDF_ENABLE_XFA_TIFF
FXCODEC_IMAGE_TYPE m_imagType;
uint32_t m_offSet;
uint8_t* m_pSrcBuf;
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index e1aec22150..e606c414bb 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -250,10 +250,6 @@ void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len,
CCodec_ProgressiveDecoder::CCodec_ProgressiveDecoder(
CCodec_ModuleMgr* pCodecMgr) {
m_pFile = nullptr;
- m_pJpegContext = nullptr;
- m_pPngContext = nullptr;
- m_pBmpContext = nullptr;
- m_pTiffContext = nullptr;
m_pCodecMgr = nullptr;
m_pSrcBuf = nullptr;
m_pDecodeBuf = nullptr;
@@ -1045,8 +1041,10 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
return PngDetectImageType(pAttribute, size);
case FXCODEC_IMAGE_GIF:
return GifDetectImageType(pAttribute, size);
- case FXCODEC_IMAGE_TIF:
- return TifDetectImageType(pAttribute, size);
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
+ return TiffDetectImageType(pAttribute, size);
+#endif // PDF_ENABLE_XFA_TIFF
default:
m_status = FXCODEC_STATUS_ERR_FORMAT;
return false;
@@ -1282,8 +1280,10 @@ bool CCodec_ProgressiveDecoder::GifDetectImageType(CFX_DIBAttribute* pAttribute,
return false;
}
-bool CCodec_ProgressiveDecoder::TifDetectImageType(CFX_DIBAttribute* pAttribute,
- uint32_t size) {
+#ifdef PDF_ENABLE_XFA_TIFF
+bool CCodec_ProgressiveDecoder::TiffDetectImageType(
+ CFX_DIBAttribute* pAttribute,
+ uint32_t size) {
CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
if (!pTiffModule) {
m_status = FXCODEC_STATUS_ERR_FORMAT;
@@ -1307,6 +1307,7 @@ bool CCodec_ProgressiveDecoder::TifDetectImageType(CFX_DIBAttribute* pAttribute,
}
return true;
}
+#endif // PDF_ENABLE_XFA_TIFF
FXCODEC_STATUS CCodec_ProgressiveDecoder::LoadImageInfo(
const RetainPtr<IFX_SeekableReadStream>& pFile,
@@ -1862,7 +1863,9 @@ std::pair<FXCODEC_STATUS, size_t> CCodec_ProgressiveDecoder::GetFrames() {
case FXCODEC_IMAGE_JPG:
case FXCODEC_IMAGE_BMP:
case FXCODEC_IMAGE_PNG:
- case FXCODEC_IMAGE_TIF:
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
+#endif // PDF_ENABLE_XFA_TIFF
m_FrameNumber = 1;
m_status = FXCODEC_STATUS_DECODE_READY;
return {m_status, 1};
@@ -1960,9 +1963,11 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::StartDecode(
return GifStartDecode(pDIBitmap);
case FXCODEC_IMAGE_BMP:
return BmpStartDecode(pDIBitmap);
- case FXCODEC_IMAGE_TIF:
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
m_status = FXCODEC_STATUS_DECODE_TOBECONTINUE;
return m_status;
+#endif // PDF_ENABLE_XFA_TIFF
default:
return FXCODEC_STATUS_ERROR;
}
@@ -2125,8 +2130,10 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::ContinueDecode() {
return GifContinueDecode();
case FXCODEC_IMAGE_BMP:
return BmpContinueDecode();
- case FXCODEC_IMAGE_TIF:
- return TifContinueDecode();
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
+ return TiffContinueDecode();
+#endif // PDF_ENABLE_XFA_TIFF
default:
return FXCODEC_STATUS_ERROR;
}
@@ -2278,7 +2285,8 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::BmpContinueDecode() {
}
}
-FXCODEC_STATUS CCodec_ProgressiveDecoder::TifContinueDecode() {
+#ifdef PDF_ENABLE_XFA_TIFF
+FXCODEC_STATUS CCodec_ProgressiveDecoder::TiffContinueDecode() {
CCodec_TiffModule* pTiffModule = m_pCodecMgr->GetTiffModule();
if (!pTiffModule) {
m_status = FXCODEC_STATUS_ERR_MEMORY;
@@ -2416,6 +2424,7 @@ FXCODEC_STATUS CCodec_ProgressiveDecoder::TifContinueDecode() {
m_status = FXCODEC_STATUS_DECODE_FINISH;
return m_status;
}
+#endif // PDF_ENABLE_XFA_TIFF
std::unique_ptr<CCodec_ProgressiveDecoder>
CCodec_ModuleMgr::CreateProgressiveDecoder() {
diff --git a/core/fxcodec/fx_codec_def.h b/core/fxcodec/fx_codec_def.h
index 3983285d6d..e4ac0437eb 100644
--- a/core/fxcodec/fx_codec_def.h
+++ b/core/fxcodec/fx_codec_def.h
@@ -30,7 +30,9 @@ enum FXCODEC_IMAGE_TYPE {
FXCODEC_IMAGE_JPG,
FXCODEC_IMAGE_PNG,
FXCODEC_IMAGE_GIF,
- FXCODEC_IMAGE_TIF,
+#ifdef PDF_ENABLE_XFA_TIFF
+ FXCODEC_IMAGE_TIFF,
+#endif // PDF_ENABLE_XFA_TIFF
FXCODEC_IMAGE_MAX
};
enum FXCODEC_RESUNIT {
diff --git a/testing/libfuzzer/BUILD.gn b/testing/libfuzzer/BUILD.gn
index ba368948e2..a45c8d2576 100644
--- a/testing/libfuzzer/BUILD.gn
+++ b/testing/libfuzzer/BUILD.gn
@@ -43,12 +43,14 @@ group("libfuzzer") {
":pdf_codec_gif_fuzzer",
":pdf_codec_jpeg_fuzzer",
":pdf_codec_png_fuzzer",
- ":pdf_codec_tiff_fuzzer",
":pdf_css_fuzzer",
":pdf_fm2js_fuzzer",
":pdf_formcalc_fuzzer",
":pdf_lzw_fuzzer",
]
+ if (pdf_enable_xfa_tiff) {
+ deps += [ ":pdf_codec_tiff_fuzzer" ]
+ }
}
}
@@ -105,11 +107,13 @@ if (pdf_enable_xfa) {
]
}
- pdfium_fuzzer("pdf_codec_tiff_fuzzer") {
- sources = [
- "pdf_codec_tiff_fuzzer.cc",
- "xfa_codec_fuzzer.h",
- ]
+ if (pdf_enable_xfa_tiff) {
+ pdfium_fuzzer("pdf_codec_tiff_fuzzer") {
+ sources = [
+ "pdf_codec_tiff_fuzzer.cc",
+ "xfa_codec_fuzzer.h",
+ ]
+ }
}
pdfium_fuzzer("pdf_css_fuzzer") {
diff --git a/testing/libfuzzer/pdf_codec_tiff_fuzzer.cc b/testing/libfuzzer/pdf_codec_tiff_fuzzer.cc
index 483ac28306..8e28d0fd12 100644
--- a/testing/libfuzzer/pdf_codec_tiff_fuzzer.cc
+++ b/testing/libfuzzer/pdf_codec_tiff_fuzzer.cc
@@ -5,5 +5,5 @@
#include "testing/libfuzzer/xfa_codec_fuzzer.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- return XFACodecFuzzer::Fuzz(data, size, FXCODEC_IMAGE_TIF);
+ return XFACodecFuzzer::Fuzz(data, size, FXCODEC_IMAGE_TIFF);
}
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 8b2e826165..6fd2397670 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -42,7 +42,10 @@ FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type,
switch (type) {
case FXCODEC_IMAGE_BMP:
case FXCODEC_IMAGE_JPG:
- case FXCODEC_IMAGE_TIF: {
+#ifdef PDF_ENABLE_XFA_TIFF
+ case FXCODEC_IMAGE_TIFF:
+#endif // PDF_ENABLE_XFA_TIFF
+ {
dibFormat = FXDIB_Rgb32;
int32_t bpp = iComponents * iBitsPerComponent;
if (bpp <= 24) {
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 91e78dc485..674ec00d8e 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -171,8 +171,10 @@ FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType) {
return FXCODEC_IMAGE_GIF;
if (wsContentType == L"image/bmp")
return FXCODEC_IMAGE_BMP;
+#ifdef PDF_ENABLE_XFA_TIFF
if (wsContentType == L"image/tif")
- return FXCODEC_IMAGE_TIF;
+ return FXCODEC_IMAGE_TIFF;
+#endif // PDF_ENABLE_XFA_TIFF
return FXCODEC_IMAGE_UNKNOWN;
}