summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-02 18:42:06 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-02 18:42:06 +0000
commit8ed949d3dcdcb826c16acc9129eaf168c2ea8134 (patch)
treef05816ea643d3e8b63072947f326db48b724e5d6
parentb07deb3fc1f54bd700a66df573bfcbc4bcc1d787 (diff)
downloadpdfium-8ed949d3dcdcb826c16acc9129eaf168c2ea8134.tar.xz
Remove some checks in IsLinearizedHeaderValid().
One check can never fail. The other check can be done earlier, before creating the CPDF_LinearizedHeader. Change-Id: I0bccb2a9e19e0d5517daf96684adba6bb3a203bf Reviewed-on: https://pdfium-review.googlesource.com/39412 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--core/fpdfapi/parser/cpdf_linearized_header.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/core/fpdfapi/parser/cpdf_linearized_header.cpp b/core/fpdfapi/parser/cpdf_linearized_header.cpp
index 8286e0fbe3..da7a7ad384 100644
--- a/core/fpdfapi/parser/cpdf_linearized_header.cpp
+++ b/core/fpdfapi/parser/cpdf_linearized_header.cpp
@@ -41,11 +41,9 @@ bool IsLinearizedHeaderValid(const CPDF_LinearizedHeader* header,
FX_FILESIZE document_size) {
ASSERT(header);
return header->GetFileSize() == document_size &&
- static_cast<int>(header->GetFirstPageNo()) >= 0 &&
header->GetFirstPageNo() < kMaxInt &&
header->GetFirstPageNo() < header->GetPageCount() &&
header->GetMainXRefTableFirstEntryOffset() < document_size &&
- header->GetPageCount() > 0 &&
header->GetFirstPageEndOffset() < document_size &&
header->GetLastXRefOffset() < document_size &&
header->GetHintStart() < document_size;
@@ -65,7 +63,7 @@ std::unique_ptr<CPDF_LinearizedHeader> CPDF_LinearizedHeader::Parse(
!IsValidNumericDictionaryValue<FX_FILESIZE>(pDict.get(), "L", 1) ||
!IsValidNumericDictionaryValue<uint32_t>(pDict.get(), "P", 0, false) ||
!IsValidNumericDictionaryValue<FX_FILESIZE>(pDict.get(), "T", 1) ||
- !IsValidNumericDictionaryValue<uint32_t>(pDict.get(), "N", 0) ||
+ !IsValidNumericDictionaryValue<uint32_t>(pDict.get(), "N", 1) ||
!IsValidNumericDictionaryValue<FX_FILESIZE>(pDict.get(), "E", 1) ||
!IsValidNumericDictionaryValue<uint32_t>(pDict.get(), "O", 1)) {
return nullptr;