summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2017-08-23 17:53:13 +0300
committerChromium commit bot <commit-bot@chromium.org>2017-08-28 20:26:03 +0000
commit03371b8bb8459b96ceefa89d6b5ba2d08683614b (patch)
tree742d30f70f24118c3d64ecf909da3171c94e6161 /core
parentd1ed1ce582efc877487c749924e21772e73df6a2 (diff)
downloadpdfium-03371b8bb8459b96ceefa89d6b5ba2d08683614b.tar.xz
Unify CPDF_DataAvail::CheckCrossRef.
Use read validator to check cross ref table availability Change-Id: I050c366a255598ca6d8bcd353afa94c4a09c33a9 Reviewed-on: https://pdfium-review.googlesource.com/11730 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.cpp15
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.h2
2 files changed, 8 insertions, 9 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index 24ba2e28b1..234a5a0b19 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -58,7 +58,6 @@ class HintsScope {
CPDF_DataAvail::DownloadHints* hints)
: validator_(validator) {
ASSERT(validator_);
- validator_->ResetErrors();
validator_->SetDownloadHints(hints);
}
@@ -272,7 +271,7 @@ bool CPDF_DataAvail::CheckDocStatus(DownloadHints* pHints) {
case PDF_DATAAVAIL_END:
return CheckEnd();
case PDF_DATAAVAIL_CROSSREF:
- return CheckCrossRef(pHints);
+ return CheckCrossRef();
case PDF_DATAAVAIL_CROSSREF_ITEM:
return CheckCrossRefItem();
case PDF_DATAAVAIL_TRAILER:
@@ -890,8 +889,9 @@ bool CPDF_DataAvail::GetNextChar(uint8_t& ch) {
bool CPDF_DataAvail::CheckCrossRefItem() {
CFX_ByteString token;
while (1) {
+ const CPDF_ReadValidator::Session read_session(GetValidator().Get());
if (!GetNextToken(&token)) {
- if (!m_pFileRead->has_read_problems())
+ if (!GetValidator()->has_read_problems())
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
@@ -904,13 +904,12 @@ bool CPDF_DataAvail::CheckCrossRefItem() {
}
}
-bool CPDF_DataAvail::CheckCrossRef(DownloadHints* pHints) {
- int32_t iSize = 0;
+bool CPDF_DataAvail::CheckCrossRef() {
+ const CPDF_ReadValidator::Session read_session(GetValidator().Get());
CFX_ByteString token;
if (!GetNextToken(&token)) {
- iSize = static_cast<int32_t>(m_Pos + 512 > m_dwFileLen ? m_dwFileLen - m_Pos
- : 512);
- pHints->AddSegment(m_Pos, iSize);
+ if (!GetValidator()->has_read_problems())
+ m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h
index db134dd3f5..e704e12900 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 CheckFirstPage(DownloadHints* pHints);
bool CheckHintTables(DownloadHints* pHints);
bool CheckEnd();
- bool CheckCrossRef(DownloadHints* pHints);
+ bool CheckCrossRef();
bool CheckCrossRefItem();
bool CheckTrailer(DownloadHints* pHints);
bool CheckRoot();