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

Side by Side Diff: core/fpdfapi/fpdf_font/cpdf_cidfont.cpp

Issue 2384853002: Detect resursive loading of type3 font char to avoid infinite loop (Closed)
Patch Set: address comments Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_cidfont.h ('k') | core/fpdfapi/fpdf_font/cpdf_font.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/fpdfapi/fpdf_font/cpdf_cidfont.h" 7 #include "core/fpdfapi/fpdf_font/cpdf_cidfont.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <vector> 10 #include <vector>
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 m_DefaultVY = pDefaultArray->GetIntegerAt(0); 421 m_DefaultVY = pDefaultArray->GetIntegerAt(0);
422 m_DefaultW1 = pDefaultArray->GetIntegerAt(1); 422 m_DefaultW1 = pDefaultArray->GetIntegerAt(1);
423 } else { 423 } else {
424 m_DefaultVY = 880; 424 m_DefaultVY = 880;
425 m_DefaultW1 = -1000; 425 m_DefaultW1 = -1000;
426 } 426 }
427 } 427 }
428 return true; 428 return true;
429 } 429 }
430 430
431 FX_RECT CPDF_CIDFont::GetCharBBox(uint32_t charcode, int level) { 431 FX_RECT CPDF_CIDFont::GetCharBBox(uint32_t charcode) {
432 if (charcode < 256 && m_CharBBox[charcode].right != -1) 432 if (charcode < 256 && m_CharBBox[charcode].right != -1)
433 return m_CharBBox[charcode]; 433 return m_CharBBox[charcode];
434 434
435 FX_RECT rect; 435 FX_RECT rect;
436 bool bVert = false; 436 bool bVert = false;
437 int glyph_index = GlyphFromCharCode(charcode, &bVert); 437 int glyph_index = GlyphFromCharCode(charcode, &bVert);
438 FXFT_Face face = m_Font.GetFace(); 438 FXFT_Face face = m_Font.GetFace();
439 if (face) { 439 if (face) {
440 if (FXFT_Is_Face_Tricky(face)) { 440 if (FXFT_Is_Face_Tricky(face)) {
441 int err = FXFT_Load_Glyph(face, glyph_index, 441 int err = FXFT_Load_Glyph(face, glyph_index,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 rect_f.Transform(&matrix); 492 rect_f.Transform(&matrix);
493 rect = rect_f.GetOuterRect(); 493 rect = rect_f.GetOuterRect();
494 } 494 }
495 } 495 }
496 if (charcode < 256) 496 if (charcode < 256)
497 m_CharBBox[charcode] = rect; 497 m_CharBBox[charcode] = rect;
498 498
499 return rect; 499 return rect;
500 } 500 }
501 501
502 int CPDF_CIDFont::GetCharWidthF(uint32_t charcode, int level) { 502 int CPDF_CIDFont::GetCharWidthF(uint32_t charcode) {
503 if (charcode < 0x80 && m_bAnsiWidthsFixed) 503 if (charcode < 0x80 && m_bAnsiWidthsFixed)
504 return (charcode >= 32 && charcode < 127) ? 500 : 0; 504 return (charcode >= 32 && charcode < 127) ? 500 : 0;
505 505
506 uint16_t cid = CIDFromCharCode(charcode); 506 uint16_t cid = CIDFromCharCode(charcode);
507 int size = m_WidthList.GetSize(); 507 int size = m_WidthList.GetSize();
508 const uint32_t* pList = m_WidthList.GetData(); 508 const uint32_t* pList = m_WidthList.GetData();
509 for (int i = 0; i < size; i += 3) { 509 for (int i = 0; i < size; i += 3) {
510 const uint32_t* pEntry = pList + i; 510 const uint32_t* pEntry = pList + i;
511 if (IsMetricForCID(pEntry, cid)) 511 if (IsMetricForCID(pEntry, cid))
512 return static_cast<int>(pEntry[2]); 512 return static_cast<int>(pEntry[2]);
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile) 843 if (m_Charset != CIDSET_JAPAN1 || m_pFontFile)
844 return nullptr; 844 return nullptr;
845 845
846 const auto* pEnd = g_Japan1_VertCIDs + FX_ArraySize(g_Japan1_VertCIDs); 846 const auto* pEnd = g_Japan1_VertCIDs + FX_ArraySize(g_Japan1_VertCIDs);
847 const auto* pTransform = std::lower_bound( 847 const auto* pTransform = std::lower_bound(
848 g_Japan1_VertCIDs, pEnd, CID, 848 g_Japan1_VertCIDs, pEnd, CID,
849 [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; }); 849 [](const CIDTransform& entry, uint16_t cid) { return entry.cid < cid; });
850 return (pTransform < pEnd && CID == pTransform->cid) ? &pTransform->a 850 return (pTransform < pEnd && CID == pTransform->cid) ? &pTransform->a
851 : nullptr; 851 : nullptr;
852 } 852 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/cpdf_cidfont.h ('k') | core/fpdfapi/fpdf_font/cpdf_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698