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

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

Issue 2358023002: Check for overflow in CMap_GetCode. (Closed)
Patch Set: Review fixes Created 4 years, 3 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 | « no previous file | core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.cpp » ('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 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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/font_int.h" 7 #include "core/fpdfapi/fpdf_font/font_int.h"
8 8
9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h" 9 #include "core/fpdfapi/fpdf_cmaps/cmap_int.h"
10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h" 10 #include "core/fpdfapi/fpdf_font/ttgsubtable.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 434 }
435 } 435 }
436 m_CodeSeq++; 436 m_CodeSeq++;
437 } 437 }
438 } 438 }
439 m_LastWord = word; 439 m_LastWord = word;
440 } 440 }
441 441
442 // Static. 442 // Static.
443 uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) { 443 uint32_t CPDF_CMapParser::CMap_GetCode(const CFX_ByteStringC& word) {
444 int num = 0; 444 pdfium::base::CheckedNumeric<uint32_t> num = 0;
445 if (word.GetAt(0) == '<') { 445 if (word.GetAt(0) == '<') {
446 for (int i = 1; i < word.GetLength() && std::isxdigit(word.GetAt(i)); ++i) 446 for (int i = 1; i < word.GetLength() && std::isxdigit(word.GetAt(i)); ++i) {
447 num = num * 16 + FXSYS_toHexDigit(word.GetAt(i)); 447 num = num * 16 + FXSYS_toHexDigit(word.GetAt(i));
448 return num; 448 if (!num.IsValid())
449 return 0;
450 }
451 return num.ValueOrDie();
449 } 452 }
450 453
451 for (int i = 0; i < word.GetLength() && std::isdigit(word.GetAt(i)); ++i) 454 for (int i = 0; i < word.GetLength() && std::isdigit(word.GetAt(i)); ++i) {
452 num = num * 10 + FXSYS_toDecimalDigit(static_cast<FX_WCHAR>(word.GetAt(i))); 455 num = num * 10 + FXSYS_toDecimalDigit(static_cast<FX_WCHAR>(word.GetAt(i)));
453 return num; 456 if (!num.IsValid())
457 return 0;
458 }
459 return num.ValueOrDie();
454 } 460 }
455 461
456 // Static. 462 // Static.
457 bool CPDF_CMapParser::CMap_GetCodeRange(CMap_CodeRange& range, 463 bool CPDF_CMapParser::CMap_GetCodeRange(CMap_CodeRange& range,
458 const CFX_ByteStringC& first, 464 const CFX_ByteStringC& first,
459 const CFX_ByteStringC& second) { 465 const CFX_ByteStringC& second) {
460 if (first.GetLength() == 0 || first.GetAt(0) != '<') 466 if (first.GetLength() == 0 || first.GetAt(0) != '<')
461 return false; 467 return false;
462 468
463 int i; 469 int i;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count; 780 m_EmbeddedCount = pFontGlobals->m_EmbeddedToUnicodes[charset].m_Count;
775 } 781 }
776 782
777 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) { 783 CIDSet CharsetFromOrdering(const CFX_ByteStringC& ordering) {
778 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) { 784 for (size_t charset = 1; charset < FX_ArraySize(g_CharsetNames); ++charset) {
779 if (ordering == g_CharsetNames[charset]) 785 if (ordering == g_CharsetNames[charset])
780 return CIDSetFromSizeT(charset); 786 return CIDSetFromSizeT(charset);
781 } 787 }
782 return CIDSET_UNKNOWN; 788 return CIDSET_UNKNOWN;
783 } 789 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_font/fpdf_font_cid_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698