From cd1e9ff4f432cbc29ed279e6891fb7ddc2ea3734 Mon Sep 17 00:00:00 2001 From: weili Date: Fri, 29 Apr 2016 10:24:02 -0700 Subject: Relax a couple checks to allow certain non-standard PDF files. Some non-standard PDF files misuse the size of cross reference table, and reuse some object number which the old one is still in use. PDFium can relax the reusing of xref objects only since it is not referred in the pdf document. When the size of cross reference table is larger than defined, PDFium will try to continue other than abort. BUG=chromium:596947 Review-Url: https://codereview.chromium.org/1926823002 --- core/fpdfapi/fpdf_parser/cpdf_parser.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core/fpdfapi/fpdf_parser/cpdf_parser.cpp') diff --git a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp index acf51de1ea..c66647846d 100644 --- a/core/fpdfapi/fpdf_parser/cpdf_parser.cpp +++ b/core/fpdfapi/fpdf_parser/cpdf_parser.cpp @@ -1077,8 +1077,13 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) { FX_SAFE_UINT32 dwMaxObjNum = startnum; dwMaxObjNum += count; uint32_t dwV5Size = m_ObjectInfo.empty() ? 0 : GetLastObjNum() + 1; - if (!dwMaxObjNum.IsValid() || dwMaxObjNum.ValueOrDie() > dwV5Size) + if (!dwMaxObjNum.IsValid()) continue; + // When the max object number is larger than the defined size, try to + // increase the size to accomodate more objects. + // Some software messes this up, see chromium:596947. + if (dwMaxObjNum.ValueOrDie() > dwV5Size) + ShrinkObjectMap(dwMaxObjNum.ValueOrDie()); for (uint32_t j = 0; j < count; j++) { int32_t type = 1; -- cgit v1.2.3