summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2017-08-23 16:22:46 +0300
committerChromium commit bot <commit-bot@chromium.org>2017-08-23 14:08:09 +0000
commita9bf2976ad2c20b8ee51de5375be5ae5e2110690 (patch)
tree3842fd0ee40f8a87ec8cd1eb5e88f13f7df8f424 /core
parent81692ab7daf5389bae1bed55c4a3a8e9e68fada4 (diff)
downloadpdfium-a9bf2976ad2c20b8ee51de5375be5ae5e2110690.tar.xz
Unify CPDF_DataAvail::CheckHeader.
Use read validator to check header availability. Change-Id: Ib482347cb2f112e27a6bcc4e8da865d0ecf1a630 Reviewed-on: https://pdfium-review.googlesource.com/11710 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.cpp16
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.h2
2 files changed, 10 insertions, 8 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index 0d87543145..93e4472d94 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -264,7 +264,7 @@ bool CPDF_DataAvail::CheckAcroForm() {
bool CPDF_DataAvail::CheckDocStatus(DownloadHints* pHints) {
switch (m_docStatus) {
case PDF_DATAAVAIL_HEADER:
- return CheckHeader(pHints);
+ return CheckHeader();
case PDF_DATAAVAIL_FIRSTPAGE:
return CheckFirstPage(pHints);
case PDF_DATAAVAIL_HINTTABLE:
@@ -560,15 +560,17 @@ bool CPDF_DataAvail::CheckPages() {
return true;
}
-bool CPDF_DataAvail::CheckHeader(DownloadHints* pHints) {
+bool CPDF_DataAvail::CheckHeader() {
ASSERT(m_dwFileLen >= 0);
const uint32_t kReqSize = std::min(static_cast<uint32_t>(m_dwFileLen), 1024U);
- if (!m_pFileAvail->IsDataAvail(0, kReqSize)) {
- pHints->AddSegment(0, kReqSize);
- return false;
- }
std::vector<uint8_t> buffer(kReqSize);
- m_pFileRead->ReadBlock(buffer.data(), 0, kReqSize);
+ {
+ const CPDF_ReadValidator::Session read_session(GetValidator().Get());
+ m_pFileRead->ReadBlock(buffer.data(), 0, kReqSize);
+ if (GetValidator()->has_read_problems())
+ return false;
+ }
+
if (IsLinearizedFile(buffer.data(), kReqSize)) {
m_docStatus = PDF_DATAAVAIL_FIRSTPAGE;
return true;
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index 30d76f3dab..dec6b30a79 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.h
+++ b/core/fpdfapi/parser/cpdf_data_avail.h
@@ -130,7 +130,7 @@ class CPDF_DataAvail final {
bool bParsePage,
std::vector<CPDF_Object*>& ret_array);
bool CheckDocStatus(DownloadHints* pHints);
- bool CheckHeader(DownloadHints* pHints);
+ bool CheckHeader();
bool CheckFirstPage(DownloadHints* pHints);
bool CheckHintTables(DownloadHints* pHints);
bool CheckEnd(DownloadHints* pHints);