diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-08-23 16:28:53 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-23 14:08:49 +0000 |
commit | f9161c6f2bee8593dd8b352c47496bf3f6faa0df (patch) | |
tree | daf99e171d8d1afefc7ac34f5eb97b52725fac7b /core/fpdfapi | |
parent | a9bf2976ad2c20b8ee51de5375be5ae5e2110690 (diff) | |
download | pdfium-f9161c6f2bee8593dd8b352c47496bf3f6faa0df.tar.xz |
Unify CPDF_DataAvail::CheckEnd.
Use read validator to check "startxref" availability.
Change-Id: I258a707e4269fe768898d74db0955302b34ccf34
Reviewed-on: https://pdfium-review.googlesource.com/11711
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi')
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 21 | ||||
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.h | 2 |
2 files changed, 12 insertions, 11 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index 93e4472d94..d298fb7249 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -270,7 +270,7 @@ bool CPDF_DataAvail::CheckDocStatus(DownloadHints* pHints) { case PDF_DATAAVAIL_HINTTABLE: return CheckHintTables(pHints); case PDF_DATAAVAIL_END: - return CheckEnd(pHints); + return CheckEnd(); case PDF_DATAAVAIL_CROSSREF: return CheckCrossRef(pHints); case PDF_DATAAVAIL_CROSSREF_ITEM: @@ -743,16 +743,17 @@ bool CPDF_DataAvail::IsLinearizedFile(uint8_t* pData, uint32_t dwLen) { return true; } -bool CPDF_DataAvail::CheckEnd(DownloadHints* pHints) { - uint32_t req_pos = (uint32_t)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); - uint32_t dwSize = (uint32_t)(m_dwFileLen - req_pos); - if (!m_pFileAvail->IsDataAvail(req_pos, dwSize)) { - pHints->AddSegment(req_pos, dwSize); - return false; - } - +bool CPDF_DataAvail::CheckEnd() { + const uint32_t req_pos = + (uint32_t)(m_dwFileLen > 1024 ? m_dwFileLen - 1024 : 0); + const uint32_t dwSize = (uint32_t)(m_dwFileLen - req_pos); std::vector<uint8_t> buffer(dwSize); - m_pFileRead->ReadBlock(buffer.data(), req_pos, dwSize); + { + const CPDF_ReadValidator::Session read_session(GetValidator().Get()); + m_pFileRead->ReadBlock(buffer.data(), req_pos, dwSize); + if (GetValidator()->has_read_problems()) + return false; + } auto file = pdfium::MakeRetain<CFX_MemoryStream>( buffer.data(), static_cast<size_t>(dwSize), false); diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index dec6b30a79..fe7b26b21d 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -133,7 +133,7 @@ class CPDF_DataAvail final { bool CheckHeader(); bool CheckFirstPage(DownloadHints* pHints); bool CheckHintTables(DownloadHints* pHints); - bool CheckEnd(DownloadHints* pHints); + bool CheckEnd(); bool CheckCrossRef(DownloadHints* pHints); bool CheckCrossRefItem(); bool CheckTrailer(DownloadHints* pHints); |