summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJun Fang <jun_fang@foxitsoftware.com>2014-11-19 18:58:01 -0800
committerJun Fang <jun_fang@foxitsoftware.com>2014-11-19 20:02:49 -0800
commitebe9e7dd7b3eca6247a9e4e2600cd1fd2cc72c2c (patch)
treed66f88f066ae5f498bab0c8e3db31739b9496287 /core
parent4a1a48e4fba80a6e32e95b90beec8fd6267f8f2c (diff)
downloadpdfium-ebe9e7dd7b3eca6247a9e4e2600cd1fd2cc72c2c.tar.xz
Merge to XFA: patch from CL 743263002
Fix blank page issues caused by too strict check Before this fix, PDF parser aborts the parsering process when detecting an error. For this case, PDF parser just gives up parsering when it detects that the length of image stream is incorrect. The solution to this case is to find the tag "endstream" and "endobj" to calculate the length rather than aborting the parsering process. BUG=433339 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/743263002
Diffstat (limited to 'core')
-rw-r--r--core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 5df4a6ff7f..b1dfc73af7 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -2433,16 +2433,13 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT
pContext->m_DataStart = m_Pos;
}
- base::CheckedNumeric<FX_FILESIZE> pos = m_Pos;
- pos += len;
- if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) {
- m_Pos = pos.ValueOrDie();
- } else {
- return NULL;
- }
-
CPDF_CryptoHandler* pCryptoHandler = objnum == (FX_DWORD)m_MetadataObjnum ? NULL : m_pCryptoHandler;
if (pCryptoHandler == NULL) {
+ base::CheckedNumeric<FX_FILESIZE> pos = m_Pos;
+ pos += len;
+ if (pos.IsValid() && pos.ValueOrDie() < m_FileLen) {
+ m_Pos = pos.ValueOrDie();
+ }
GetNextWord();
if (m_WordSize < 9 || FXSYS_memcmp32(m_WordBuffer, "endstream", 9)) {
m_Pos = StreamStartPos;
@@ -2473,8 +2470,8 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT
}
}
}
+ m_Pos = StreamStartPos;
}
- m_Pos = StreamStartPos;
CPDF_Stream* pStream;
#if defined(_FPDFAPI_MINI_) && !defined(_FXCORE_FEATURE_ALL_)
pStream = FX_NEW CPDF_Stream(m_pFileAccess, pCryptoHandler, m_HeaderOffset + m_Pos, len, pDict, gennum);