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

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

Issue 2230883003: Relax a check in CPDF_HintTables. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: more Created 4 years, 4 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_data_avail.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (i == 0) 289 if (i == 0)
290 m_szSharedObjOffsetArray.push_back(m_szFirstPageObjOffset); 290 m_szSharedObjOffsetArray.push_back(m_szFirstPageObjOffset);
291 } else { 291 } else {
292 FX_SAFE_UINT32 safeObjNum = dwFirstSharedObjNum; 292 FX_SAFE_UINT32 safeObjNum = dwFirstSharedObjNum;
293 safeObjNum += i - m_nFirstPageSharedObjs; 293 safeObjNum += i - m_nFirstPageSharedObjs;
294 if (!safeObjNum.IsValid()) 294 if (!safeObjNum.IsValid())
295 return FALSE; 295 return FALSE;
296 296
297 m_dwSharedObjNumArray.Add(safeObjNum.ValueOrDie()); 297 m_dwSharedObjNumArray.Add(safeObjNum.ValueOrDie());
298 if (i == m_nFirstPageSharedObjs) { 298 if (i == m_nFirstPageSharedObjs) {
299 m_szSharedObjOffsetArray.push_back( 299 FX_SAFE_FILESIZE safeLoc = dwFirstSharedObjLoc;
300 pdfium::base::checked_cast<int32_t>(dwFirstSharedObjLoc)); 300 if (!safeLoc.IsValid())
301 return FALSE;
302
303 m_szSharedObjOffsetArray.push_back(safeLoc.ValueOrDie());
301 } 304 }
302 } 305 }
303 306
304 if (i != 0 && i != m_nFirstPageSharedObjs) { 307 if (i != 0 && i != m_nFirstPageSharedObjs) {
305 FX_SAFE_INT32 safeLoc = pdfium::base::checked_cast<int32_t>(dwPrevObjLen); 308 FX_SAFE_FILESIZE safeLoc = dwPrevObjLen;
306 safeLoc += m_szSharedObjOffsetArray[i - 1]; 309 safeLoc += m_szSharedObjOffsetArray[i - 1];
307 if (!safeLoc.IsValid()) 310 if (!safeLoc.IsValid())
308 return FALSE; 311 return FALSE;
309 312
310 m_szSharedObjOffsetArray.push_back(safeLoc.ValueOrDie()); 313 m_szSharedObjOffsetArray.push_back(safeLoc.ValueOrDie());
311 } 314 }
312 } 315 }
313 316
314 if (dwSharedObjTotal > 0) { 317 if (dwSharedObjTotal > 0) {
315 FX_SAFE_INT32 safeLoc = pdfium::base::checked_cast<int32_t>(dwCurObjLen); 318 FX_SAFE_FILESIZE safeLoc = dwCurObjLen;
316 safeLoc += m_szSharedObjOffsetArray[dwSharedObjTotal - 1]; 319 safeLoc += m_szSharedObjOffsetArray[dwSharedObjTotal - 1];
317 if (!safeLoc.IsValid()) 320 if (!safeLoc.IsValid())
318 return FALSE; 321 return FALSE;
319 322
320 m_szSharedObjOffsetArray.push_back(safeLoc.ValueOrDie()); 323 m_szSharedObjOffsetArray.push_back(safeLoc.ValueOrDie());
321 } 324 }
322 325
323 hStream->ByteAlign(); 326 hStream->ByteAlign();
324 if (hStream->BitsRemaining() < dwSharedObjTotal) 327 if (hStream->BitsRemaining() < dwSharedObjTotal)
325 return FALSE; 328 return FALSE;
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); 479 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H");
477 if (!pRange) 480 if (!pRange)
478 return -1; 481 return -1;
479 482
480 CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(1); 483 CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(1);
481 if (!pStreamLen) 484 if (!pStreamLen)
482 return -1; 485 return -1;
483 486
484 return pStreamLen->GetInteger(); 487 return pStreamLen->GetInteger();
485 } 488 }
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