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

Unified Diff: core/fxcodec/codec/fx_codec_icc.cpp

Issue 2535663005: M55: pdfium: Fix inconsistent number of color components of ICC profile (Closed)
Patch Set: Created 4 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxcodec/codec/fx_codec_icc.cpp
diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp
index 8e48bfbfeaa935458ba8240351820ecaec4e880a..900faa1d0c2050e182ba4a2568dbfcb32983abd6 100644
--- a/core/fxcodec/codec/fx_codec_icc.cpp
+++ b/core/fxcodec/codec/fx_codec_icc.cpp
@@ -8,12 +8,6 @@
#include "core/fxcodec/fx_codec.h"
#include "third_party/lcms2-2.6/include/lcms2.h"
-const uint32_t N_COMPONENT_LAB = 3;
-const uint32_t N_COMPONENT_GRAY = 1;
-const uint32_t N_COMPONENT_RGB = 3;
-const uint32_t N_COMPONENT_CMYK = 4;
-const uint32_t N_COMPONENT_DEFAULT = 3;
-
struct CLcmsCmm {
cmsHTRANSFORM m_hTransform;
int m_nSrcComponents;
@@ -59,28 +53,6 @@ FX_BOOL CheckComponents(cmsColorSpaceSignature cs,
return TRUE;
}
-uint32_t GetCSComponents(cmsColorSpaceSignature cs) {
- uint32_t components;
- switch (cs) {
- case cmsSigLabData:
- components = N_COMPONENT_LAB;
- break;
- case cmsSigGrayData:
- components = N_COMPONENT_GRAY;
- break;
- case cmsSigRgbData:
- components = N_COMPONENT_RGB;
- break;
- case cmsSigCmykData:
- components = N_COMPONENT_CMYK;
- break;
- default:
- components = N_COMPONENT_DEFAULT;
- break;
- }
- return components;
-}
-
void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
uint32_t dwSrcProfileSize,
uint32_t& nSrcComponents,
@@ -110,7 +82,15 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData,
int srcFormat;
FX_BOOL bLab = FALSE;
cmsColorSpaceSignature srcCS = cmsGetColorSpace(srcProfile);
- nSrcComponents = GetCSComponents(srcCS);
+
+ nSrcComponents = cmsChannelsOf(srcCS);
+ // According to PDF spec, number of components must be 1, 3, or 4.
+ if (nSrcComponents != 1 && nSrcComponents != 3 && nSrcComponents != 4) {
+ cmsCloseProfile(srcProfile);
+ cmsCloseProfile(dstProfile);
+ return nullptr;
+ }
+
if (srcCS == cmsSigLabData) {
srcFormat =
COLORSPACE_SH(PT_Lab) | CHANNELS_SH(nSrcComponents) | BYTES_SH(0);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698