summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_parser.cpp
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-07-25 02:28:35 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-25 02:28:35 +0000
commit70ddc1ca22ad44a77006491b604a75f6514a4aa8 (patch)
tree1aab47245a415069f425fac877fd361352fb2a27 /core/fpdfapi/parser/cpdf_parser.cpp
parent36b2059cae7fc851c9f35babd35ec82a7a5d9694 (diff)
downloadpdfium-70ddc1ca22ad44a77006491b604a75f6514a4aa8.tar.xz
Use document size instead of file size while parsing.
We should use document size instead of File size, because all offsets and sizes was read from document should take into account of header offset. Added some tests of parsing of documents with header offset. Also drop friendship of CPDF_SyntaxParser with CPDF_Parser. Change-Id: Iebec75ab2ee07fb644a6c653b4ef5c2e09af09fe Reviewed-on: https://pdfium-review.googlesource.com/35830 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_parser.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index 16077fd39e..be18560ffc 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -119,10 +119,6 @@ bool CPDF_Parser::IsObjectFree(uint32_t objnum) const {
return GetObjectType(objnum) == ObjectType::kFree;
}
-RetainPtr<IFX_SeekableReadStream> CPDF_Parser::GetFileAccess() const {
- return m_pSyntax->GetFileAccess();
-}
-
void CPDF_Parser::ShrinkObjectMap(uint32_t objnum) {
m_CrossRefTable->ShrinkObjectMap(objnum);
}
@@ -230,8 +226,7 @@ CPDF_Parser::Error CPDF_Parser::StartParseInternal() {
FX_FILESIZE CPDF_Parser::ParseStartXRef() {
static constexpr char kStartXRefKeyword[] = "startxref";
- m_pSyntax->SetPos(m_pSyntax->m_FileLen - m_pSyntax->m_HeaderOffset -
- strlen(kStartXRefKeyword));
+ m_pSyntax->SetPos(m_pSyntax->GetDocumentSize() - strlen(kStartXRefKeyword));
if (!m_pSyntax->BackwardsSearchToWord(kStartXRefKeyword, 4096))
return 0;
@@ -245,7 +240,7 @@ FX_FILESIZE CPDF_Parser::ParseStartXRef() {
return 0;
const FX_SAFE_FILESIZE result = FXSYS_atoi64(xrefpos_str.c_str());
- if (!result.IsValid() || result.ValueOrDie() >= GetFileAccess()->GetSize())
+ if (!result.IsValid() || result.ValueOrDie() >= m_pSyntax->GetDocumentSize())
return 0;
return result.ValueOrDie();
@@ -453,7 +448,7 @@ bool CPDF_Parser::ParseAndAppendCrossRefSubsectionData(
return false;
const size_t max_entries_in_file =
- m_pSyntax->GetFileAccess()->GetSize() / kEntryConstSize;
+ m_pSyntax->GetDocumentSize() / kEntryConstSize;
if (new_size.ValueOrDie() > max_entries_in_file)
return false;