summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-01-17 21:15:57 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-17 21:15:57 +0000
commit4c431bab10ab8ec3681f88be4f62002de069eeb6 (patch)
treed72cc4dbee2e25c70f319c690adff84dc6745dc1 /core/fxcodec
parent4c451ba43b19c2679467bbb7d7502b3596224038 (diff)
downloadpdfium-4c431bab10ab8ec3681f88be4f62002de069eeb6.tar.xz
Move jpeg header read error handling up a level
This move the setjmp needed for handling fatal errors in the jpeg library up a level to be in line with how other instances of this are being modified. This additionally reduces the number of times that setjmp needs to be called and documents why it is occuring. BUG=pdfium:986 Change-Id: Ia57821e1ce65aae811618effb3f2fa6256e1ab8c Reviewed-on: https://pdfium-review.googlesource.com/23115 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/codec/fx_codec_jpeg.cpp3
-rw-r--r--core/fxcodec/codec/fx_codec_progress.cpp8
2 files changed, 8 insertions, 3 deletions
diff --git a/core/fxcodec/codec/fx_codec_jpeg.cpp b/core/fxcodec/codec/fx_codec_jpeg.cpp
index 4d4adfd817..f7cf291bbf 100644
--- a/core/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/fxcodec/codec/fx_codec_jpeg.cpp
@@ -459,9 +459,6 @@ int CCodec_JpegModule::ReadHeader(Context* pContext,
int* nComps) {
#endif // PDF_ENABLE_XFA
auto* ctx = static_cast<CJpegContext*>(pContext);
- if (setjmp(ctx->m_JumpMark) == -1)
- return 1;
-
int ret = jpeg_read_header(&ctx->m_Info, true);
if (ret == JPEG_SUSPENDED)
return 2;
diff --git a/core/fxcodec/codec/fx_codec_progress.cpp b/core/fxcodec/codec/fx_codec_progress.cpp
index c9436186ab..c3005bca95 100644
--- a/core/fxcodec/codec/fx_codec_progress.cpp
+++ b/core/fxcodec/codec/fx_codec_progress.cpp
@@ -1105,6 +1105,14 @@ bool CCodec_ProgressiveDecoder::DetectImageType(FXCODEC_IMAGE_TYPE imageType,
}
m_offSet += size;
pJpegModule->Input(m_pJpegContext.get(), m_pSrcBuf, size);
+ // Setting jump marker before calling ReadHeader, since a longjmp to
+ // the marker indicates a fatal error.
+ if (setjmp(*m_pJpegContext->GetJumpMark()) == -1) {
+ m_pJpegContext.reset();
+ m_status = FXCODEC_STATUS_ERR_FORMAT;
+ return false;
+ }
+
int32_t readResult =
pJpegModule->ReadHeader(m_pJpegContext.get(), &m_SrcWidth,
&m_SrcHeight, &m_SrcComponents, pAttribute);