diff options
author | Henrique Nakashima <hnakashima@chromium.org> | 2017-12-18 19:33:13 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-12-18 19:33:13 +0000 |
commit | a8fdbe4595a991436796244d1a577b6239866e53 (patch) | |
tree | 691b2e4ed8cee57961cf822f080a3d1638ee919f | |
parent | 1980f10ff2b869f14c409b712eea6744941ebd88 (diff) | |
download | pdfium-a8fdbe4595a991436796244d1a577b6239866e53.tar.xz |
[Merge M64] Add restrictions to alternate color spaces.
- ICC color spaces cannot have a Pattern color space as Alternate
- Separation and DeviceN color spaces cannot have a special color space
as Alternate. Special color spaces are {Separation, DeviceN, Indexed and
Pattern}.
Bug: chromium:794492
Change-Id: Ia2199382c759d8d1d13c605c22d6495e935265ad
Reviewed-on: https://pdfium-review.googlesource.com/21310
Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
(cherry picked from commit d92073b756277d2d4c9c839dd5ac8fa0e8bb9e28)
Reviewed-on: https://pdfium-review.googlesource.com/21590
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
-rw-r--r-- | core/fpdfapi/page/cpdf_colorspace.cpp | 9 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_colorspace.h | 5 |
2 files changed, 14 insertions, 0 deletions
diff --git a/core/fpdfapi/page/cpdf_colorspace.cpp b/core/fpdfapi/page/cpdf_colorspace.cpp index f9214c75d6..df38b020a3 100644 --- a/core/fpdfapi/page/cpdf_colorspace.cpp +++ b/core/fpdfapi/page/cpdf_colorspace.cpp @@ -947,6 +947,9 @@ bool CPDF_ICCBasedCS::FindAlternateProfile(CPDF_Document* pDoc, if (!pAlterCS) return false; + if (pAlterCS->GetFamily() == PDFCS_PATTERN) + return false; + if (pAlterCS->CountComponents() != m_nComponents) return false; @@ -1102,6 +1105,9 @@ bool CPDF_SeparationCS::v_Load(CPDF_Document* pDoc, if (!m_pAltCS) return false; + if (m_pAltCS->IsSpecial()) + return false; + CPDF_Object* pFuncObj = pArray->GetDirectObjectAt(3); if (pFuncObj && !pFuncObj->IsName()) m_pFunc = CPDF_Function::Load(pFuncObj); @@ -1181,6 +1187,9 @@ bool CPDF_DeviceNCS::v_Load(CPDF_Document* pDoc, if (!m_pAltCS || !m_pFunc) return false; + if (m_pAltCS->IsSpecial()) + return false; + return m_pFunc->CountOutputs() >= m_pAltCS->CountComponents(); } diff --git a/core/fpdfapi/page/cpdf_colorspace.h b/core/fpdfapi/page/cpdf_colorspace.h index ff10dfce6a..9bd7c8d529 100644 --- a/core/fpdfapi/page/cpdf_colorspace.h +++ b/core/fpdfapi/page/cpdf_colorspace.h @@ -57,6 +57,11 @@ class CPDF_ColorSpace { void GetDefaultColor(float* buf) const; uint32_t CountComponents() const; int GetFamily() const { return m_Family; } + bool IsSpecial() const { + return GetFamily() == PDFCS_SEPARATION || GetFamily() == PDFCS_DEVICEN || + GetFamily() == PDFCS_INDEXED || GetFamily() == PDFCS_PATTERN; + } + virtual void GetDefaultValue(int iComponent, float* value, float* min, |