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

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1589783004: Merge to XFA: Loose checking for trailer's size field (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 11 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 | fpdfsdk/src/fpdfview_embeddertest.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/include/fpdfapi/fpdf_parser.h" 7 #include "core/include/fpdfapi/fpdf_parser.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) { 371 FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
372 if (!LoadCrossRefV4(xrefpos, 0, TRUE)) { 372 if (!LoadCrossRefV4(xrefpos, 0, TRUE)) {
373 return FALSE; 373 return FALSE;
374 } 374 }
375 m_pTrailer = LoadTrailerV4(); 375 m_pTrailer = LoadTrailerV4();
376 if (!m_pTrailer) { 376 if (!m_pTrailer) {
377 return FALSE; 377 return FALSE;
378 } 378 }
379 379
380 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size"); 380 int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
381 if (xrefsize <= 0 || xrefsize > kMaxXRefSize) { 381 if (xrefsize > 0 && xrefsize <= kMaxXRefSize) {
382 return FALSE; 382 ShrinkObjectMap(xrefsize);
383 m_V5Type.SetSize(xrefsize);
383 } 384 }
384 ShrinkObjectMap(xrefsize); 385
385 m_V5Type.SetSize(xrefsize);
386 CFX_FileSizeArray CrossRefList; 386 CFX_FileSizeArray CrossRefList;
387 CFX_FileSizeArray XRefStreamList; 387 CFX_FileSizeArray XRefStreamList;
388 CrossRefList.Add(xrefpos); 388 CrossRefList.Add(xrefpos);
389 XRefStreamList.Add(GetDirectInteger(m_pTrailer, "XRefStm")); 389 XRefStreamList.Add(GetDirectInteger(m_pTrailer, "XRefStm"));
390 390
391 std::set<FX_FILESIZE> seen_xrefpos; 391 std::set<FX_FILESIZE> seen_xrefpos;
392 seen_xrefpos.insert(xrefpos); 392 seen_xrefpos.insert(xrefpos);
393 // When |m_pTrailer| doesn't have Prev entry or Prev entry value is not 393 // When |m_pTrailer| doesn't have Prev entry or Prev entry value is not
394 // numerical, GetDirectInteger() returns 0. Loading will end. 394 // numerical, GetDirectInteger() returns 0. Loading will end.
395 xrefpos = GetDirectInteger(m_pTrailer, "Prev"); 395 xrefpos = GetDirectInteger(m_pTrailer, "Prev");
(...skipping 4598 matching lines...) Expand 10 before | Expand all | Expand 10 after
4994 if (!m_pLinearizedDict) 4994 if (!m_pLinearizedDict)
4995 return -1; 4995 return -1;
4996 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H"); 4996 CPDF_Array* pRange = m_pLinearizedDict->GetArray("H");
4997 if (!pRange) 4997 if (!pRange)
4998 return -1; 4998 return -1;
4999 CPDF_Object* pStreamLen = pRange->GetElementValue(1); 4999 CPDF_Object* pStreamLen = pRange->GetElementValue(1);
5000 if (!pStreamLen) 5000 if (!pStreamLen)
5001 return -1; 5001 return -1;
5002 return pStreamLen->GetInteger(); 5002 return pStreamLen->GetInteger();
5003 } 5003 }
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/src/fpdfview_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698