summaryrefslogtreecommitdiff
path: root/core/src/fpdfapi/fpdf_font
diff options
context:
space:
mode:
authorJun Fang <jun_fang@foxitsoftware.com>2015-04-09 09:59:41 -0700
committerJun Fang <jun_fang@foxitsoftware.com>2015-04-09 09:59:41 -0700
commit1ed2ceb70476b135a3dedbb45549d6b3bc6ecdea (patch)
tree315f30c198dc74541008a08a800abf0a1d46d8a1 /core/src/fpdfapi/fpdf_font
parentcbcc7305fd8d0d0fbed316ed092642de10c3b207 (diff)
downloadpdfium-1ed2ceb70476b135a3dedbb45549d6b3bc6ecdea.tar.xz
Fix a global buffer overflow in GCPDF_CIDFont::_CharCodeFromUnicodechromium/2368chromium/2367chromium/2366chromium/2365chromium/2364
There is not a code page (CP) used for converting unicode to mutli-bytes if the coding scheme is CID coding. Only return 0 if CID can't be retrieved. The difference on Windows and other platforms should be the function used for converting rather than others. BUG=466790 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1074653002
Diffstat (limited to 'core/src/fpdfapi/fpdf_font')
-rw-r--r--core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
index cbfa19d084..1ce91f9ed6 100644
--- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
+++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp
@@ -830,6 +830,12 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const
break;
}
}
+
+ if (unicode < 0x80) {
+ return static_cast<FX_DWORD>(unicode);
+ } else if (m_pCMap->m_Coding == CIDCODING_CID) {
+ return 0;
+ }
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
FX_BYTE buffer[32];
int ret = FXSYS_WideCharToMultiByte(g_CharsetCPs[m_pCMap->m_Coding], 0, &unicode, 1, (char*)buffer, 4, NULL, NULL);
@@ -840,15 +846,10 @@ FX_DWORD CPDF_CIDFont::_CharCodeFromUnicode(FX_WCHAR unicode) const
}
return 0;
#endif
- if (unicode < 0x80) {
- return (FX_DWORD)unicode;
- } else {
- if (m_pCMap->m_pEmbedMap) {
- return _EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, unicode);
- } else {
- return 0;
- }
+ if (m_pCMap->m_pEmbedMap) {
+ return _EmbeddedCharcodeFromUnicode(m_pCMap->m_pEmbedMap, m_pCMap->m_Charset, unicode);
}
+ return 0;
}
static void FT_UseCIDCharmap(FXFT_Face face, int coding)
{