diff options
author | Artem Strygin <art-snake@yandex-team.ru> | 2017-10-02 22:08:44 +0300 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-04 15:41:16 +0000 |
commit | a5fc8975c865dc3cc90de8ff46ca13fb46c13391 (patch) | |
tree | 36b38e781140fc31eeec8a55d85299911117ac2b /core/fpdfapi/parser/cpdf_data_avail.cpp | |
parent | 4db6e37b18648dfe2c94b672276c7bf6554fd9d4 (diff) | |
download | pdfium-a5fc8975c865dc3cc90de8ff46ca13fb46c13391.tar.xz |
Unify parsing of cross ref table v4.
We can use 'Prev' value of first-page cross-reference table trailer
for load main cross-reference table,
instead of 'T' value of Linearized header (Offset of first entry in main cross-reference table).
This is better solution, because this is allow us check entry count in main cross-ref table and
unify loading of main cross-ref table with loading methods of non linearized document.
See PDF specification:
http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf#678
(page 678, Example 3/part 3)
Change-Id: I59dcf3c73a0fb561221ded78e827e40535dbd717
Reviewed-on: https://pdfium-review.googlesource.com/13810
Commit-Queue: Art Snake <art-snake@yandex-team.ru>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_data_avail.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_data_avail.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index 38e857f22f..91fc8c1087 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -1171,13 +1171,22 @@ CPDF_DataAvail::DocAvailStatus CPDF_DataAvail::CheckLinearizedData() { return DataError; if (!m_bMainXRefLoadTried) { + ASSERT(m_pDocument->GetParser()->GetTrailer()); + const FX_SAFE_FILESIZE main_xref_offset = + m_pDocument->GetParser()->GetTrailer()->GetIntegerFor("Prev"); + if (!main_xref_offset.IsValid()) + return DataError; + + if (main_xref_offset.ValueOrDie() == 0) + return DataAvailable; + FX_SAFE_SIZE_T data_size = m_dwFileLen; - data_size -= m_pLinearized->GetLastXRefOffset(); + data_size -= main_xref_offset.ValueOrDie(); if (!data_size.IsValid()) return DataError; if (!GetValidator()->CheckDataRangeAndRequestIfUnavailable( - m_pLinearized->GetLastXRefOffset(), data_size.ValueOrDie())) + main_xref_offset.ValueOrDie(), data_size.ValueOrDie())) return DataNotAvailable; CPDF_Parser::Error eRet = |