summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
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);