diff options
author | kcwu <kcwu@chromium.org> | 2016-11-09 06:15:11 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-11-09 06:15:11 -0800 |
commit | 1e21c0d076cc6cc61f36a1835dc886f721fdc4d6 (patch) | |
tree | c5fcd4811d4490b2c7063eaea623980d70f6f741 /core/fxcodec/codec | |
parent | 4f610efcf4e34779d27c5e822e639a984bab1c96 (diff) | |
download | pdfium-1e21c0d076cc6cc61f36a1835dc886f721fdc4d6.tar.xz |
Revert of Clean up fx_codec_icc.cpp (patchset #1 id:1 of https://codereview.chromium.org/2482663002/ )
Reason for revert:
Max cmsChannelsOf() is 15, which is larger than expectation of existing code and cause crashes (at least the fuzzer).
BUG=chromium:663240
Original issue's description:
> Clean up fx_codec_icc.cpp
>
> Committed: https://pdfium.googlesource.com/pdfium/+/a94fc11866adb1b9ca4a4e1afb4fb574ed472e07
TBR=dsinclair@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
Review-Url: https://codereview.chromium.org/2485363002
Diffstat (limited to 'core/fxcodec/codec')
-rw-r--r-- | core/fxcodec/codec/fx_codec_icc.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/core/fxcodec/codec/fx_codec_icc.cpp b/core/fxcodec/codec/fx_codec_icc.cpp index 1be4d48518..085452223d 100644 --- a/core/fxcodec/codec/fx_codec_icc.cpp +++ b/core/fxcodec/codec/fx_codec_icc.cpp @@ -8,6 +8,12 @@ #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; @@ -51,6 +57,28 @@ bool CheckComponents(cmsColorSpaceSignature cs, int nComponents, bool bDst) { 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, @@ -80,7 +108,7 @@ void* IccLib_CreateTransform(const unsigned char* pSrcProfileData, int srcFormat; bool bLab = false; cmsColorSpaceSignature srcCS = cmsGetColorSpace(srcProfile); - nSrcComponents = cmsChannelsOf(srcCS); + nSrcComponents = GetCSComponents(srcCS); if (srcCS == cmsSigLabData) { srcFormat = COLORSPACE_SH(PT_Lab) | CHANNELS_SH(nSrcComponents) | BYTES_SH(0); |