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

Side by Side Diff: core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp

Issue 2274723002: Fix one more integer overflow in ReadPageHintTable(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: 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 | no next file » | 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_parser/cpdf_hint_tables.h" 7 #include "core/fpdfapi/fpdf_parser/cpdf_hint_tables.h"
8 8
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 if (!dwSharedIdBits) 115 if (!dwSharedIdBits)
116 return FALSE; 116 return FALSE;
117 117
118 // Item 13: Skip Item 13 which has 16 bits. 118 // Item 13: Skip Item 13 which has 16 bits.
119 hStream->SkipBits(16); 119 hStream->SkipBits(16);
120 120
121 // Sanity check values from the page table header. 2^|kMaxBits| should be more 121 // Sanity check values from the page table header. 2^|kMaxBits| should be more
122 // than enough to represent most of the values here. 122 // than enough to represent most of the values here.
123 constexpr uint32_t kMaxBits = 34; 123 constexpr uint32_t kMaxBits = 34;
124 if (dwSharedObjBits > kMaxBits || dwDeltaObjectsBits > kMaxBits || 124 if (dwSharedObjBits > kMaxBits || dwDeltaObjectsBits > kMaxBits ||
125 dwSharedIdBits > kMaxBits) { 125 dwDeltaPageLenBits > kMaxBits || dwSharedIdBits > kMaxBits) {
126 return false; 126 return false;
127 } 127 }
128 128
129 const int nPages = GetNumberOfPages(); 129 const int nPages = GetNumberOfPages();
130 if (nPages < 1 || nPages >= FPDF_PAGE_MAX_NUM) 130 if (nPages < 1 || nPages >= FPDF_PAGE_MAX_NUM)
131 return false; 131 return false;
132 132
133 const uint32_t dwPages = pdfium::base::checked_cast<uint32_t>(nPages); 133 const uint32_t dwPages = pdfium::base::checked_cast<uint32_t>(nPages);
134 FX_SAFE_UINT32 required_bits = dwDeltaObjectsBits; 134 FX_SAFE_UINT32 required_bits = dwDeltaObjectsBits;
135 required_bits *= dwPages; 135 required_bits *= dwPages;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 } 491 }
492 492
493 int CPDF_HintTables::ReadPrimaryHintStream(int index) const { 493 int CPDF_HintTables::ReadPrimaryHintStream(int index) const {
494 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); 494 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H");
495 if (!pRange) 495 if (!pRange)
496 return -1; 496 return -1;
497 497
498 CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(index); 498 CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(index);
499 return pStreamLen ? pStreamLen->GetInteger() : -1; 499 return pStreamLen ? pStreamLen->GetInteger() : -1;
500 } 500 }
OLDNEW
« 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