diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2018-07-25 02:28:35 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-25 02:28:35 +0000 |
commit | 70ddc1ca22ad44a77006491b604a75f6514a4aa8 (patch) | |
tree | 1aab47245a415069f425fac877fd361352fb2a27 /core/fpdfapi/parser/cpdf_syntax_parser.cpp | |
parent | 36b2059cae7fc851c9f35babd35ec82a7a5d9694 (diff) | |
download | pdfium-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_syntax_parser.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp index f8f36aee11..af5ff488db 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp @@ -112,6 +112,10 @@ bool CPDF_SyntaxParser::GetNextChar(uint8_t& ch) { return true; } +FX_FILESIZE CPDF_SyntaxParser::GetDocumentSize() const { + return m_FileLen - m_HeaderOffset; +} + bool CPDF_SyntaxParser::GetCharAtBackward(FX_FILESIZE pos, uint8_t* ch) { pos += m_HeaderOffset; if (pos >= m_FileLen) @@ -714,6 +718,7 @@ void CPDF_SyntaxParser::InitParserWithValidator( m_pFileBuf.clear(); m_HeaderOffset = HeaderOffset; m_FileLen = validator->GetSize(); + ASSERT(m_HeaderOffset <= m_FileLen); m_Pos = 0; m_pFileAccess = validator; m_BufOffset = 0; @@ -813,10 +818,6 @@ FX_FILESIZE CPDF_SyntaxParser::FindTag(const ByteStringView& tag) { return -1; } -RetainPtr<IFX_SeekableReadStream> CPDF_SyntaxParser::GetFileAccess() const { - return m_pFileAccess; -} - bool CPDF_SyntaxParser::IsPositionRead(FX_FILESIZE pos) const { return m_BufOffset <= pos && pos < static_cast<FX_FILESIZE>(m_BufOffset + m_pFileBuf.size()); |