Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp

Issue 892553002: Fix JPX image rendering that regressed due to several security fixes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
index a805ffa463ed52cd64da9ffce5b23c3c602e1fcd..79d73518a18c1235fbb62b0b14ae1342cc2c5783 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp
@@ -119,6 +119,7 @@ CPDF_DIBSource::CPDF_DIBSource()
m_pColorSpace = NULL;
m_bDefaultDecode = TRUE;
m_bImageMask = FALSE;
+ m_bDoBpcCheck = TRUE;
m_pPalette = NULL;
m_pCompData = NULL;
m_bColorKey = FALSE;
@@ -197,7 +198,7 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream, CP
if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPageResources)) {
return FALSE;
}
- if (m_bpc == 0 || m_nComponents == 0) {
+ if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) {
return FALSE;
}
FX_SAFE_DWORD src_pitch =
@@ -210,10 +211,6 @@ FX_BOOL CPDF_DIBSource::Load(CPDF_Document* pDoc, const CPDF_Stream* pStream, CP
if (m_pStreamAcc->GetSize() == 0 || m_pStreamAcc->GetData() == NULL) {
return FALSE;
}
- const CFX_ByteString& decoder = m_pStreamAcc->GetImageDecoder();
- if (!decoder.IsEmpty() && decoder == FX_BSTRC("CCITTFaxDecode")) {
- m_bpc = 1;
- }
if (!CreateDecoder()) {
return FALSE;
}
@@ -316,7 +313,7 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Stream* p
if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPageResources)) {
return 0;
}
- if (m_bpc == 0 || m_nComponents == 0) {
+ if (m_bDoBpcCheck && (m_bpc == 0 || m_nComponents == 0)) {
return 0;
}
FX_SAFE_DWORD src_pitch =
@@ -446,11 +443,13 @@ FX_BOOL CPDF_DIBSource::LoadColorInfo(CPDF_Dictionary* pFormResources, CPDF_Dict
if (pFilter->GetType() == PDFOBJ_NAME) {
filter = pFilter->GetString();
if (filter == FX_BSTRC("JPXDecode")) {
+ m_bDoBpcCheck = FALSE;
return TRUE;
}
} else if (pFilter->GetType() == PDFOBJ_ARRAY) {
CPDF_Array* pArray = (CPDF_Array*)pFilter;
if (pArray->GetString(pArray->GetCount() - 1) == FX_BSTRC("JPXDecode")) {
+ m_bDoBpcCheck = FALSE;
return TRUE;
}
}
@@ -560,7 +559,7 @@ int CPDF_DIBSource::CreateDecoder()
if (decoder.IsEmpty()) {
return 1;
}
- if (m_bpc == 0) {
+ if (m_bDoBpcCheck && m_bpc == 0) {
return 0;
}
FX_LPCBYTE src_data = m_pStreamAcc->GetData();
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698