diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-13 18:05:38 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-13 18:05:38 +0000 |
commit | e03171e52ec4232369ab3b46e11d3a0abe1eb630 (patch) | |
tree | 6a57f6a0948032e6ec387c22d8b462215e6ca1e4 /core/fpdfapi/parser/cpdf_linearized_header.cpp | |
parent | 8bbfdf2fca7197a0eccfef7b6fc27c590a44e7f7 (diff) | |
parent | 326d96bf5d52fdcf790b467b13f58ba3df3e81e4 (diff) | |
download | pdfium-android14-platform-release.tar.gz |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/23916086'] into udc-platform-release.android-platform-14.0.0_r8android-platform-14.0.0_r7android-platform-14.0.0_r6android-platform-14.0.0_r5android-platform-14.0.0_r4android14-platform-release
Change-Id: If925f85c6a039b56ff549fd5327795f57b9cd12c
Diffstat (limited to 'core/fpdfapi/parser/cpdf_linearized_header.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_linearized_header.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/core/fpdfapi/parser/cpdf_linearized_header.cpp b/core/fpdfapi/parser/cpdf_linearized_header.cpp index c7dc54ac5..f4de7d7a2 100644 --- a/core/fpdfapi/parser/cpdf_linearized_header.cpp +++ b/core/fpdfapi/parser/cpdf_linearized_header.cpp @@ -1,4 +1,4 @@ -// Copyright 2016 PDFium Authors. All rights reserved. +// Copyright 2016 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,8 +13,10 @@ #include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" #include "core/fpdfapi/parser/cpdf_number.h" +#include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfapi/parser/cpdf_syntax_parser.h" #include "core/fxcrt/fx_safe_types.h" +#include "third_party/base/check.h" #include "third_party/base/ptr_util.h" namespace { @@ -24,12 +26,12 @@ constexpr size_t kMaxInt = static_cast<size_t>(std::numeric_limits<int>::max()); template <class T> bool IsValidNumericDictionaryValue(const CPDF_Dictionary* pDict, - const char* key, + const ByteString& key, T min_value, bool must_exist = true) { if (!pDict->KeyExist(key)) return !must_exist; - const CPDF_Number* pNum = ToNumber(pDict->GetObjectFor(key)); + RetainPtr<const CPDF_Number> pNum = pDict->GetNumberFor(key); if (!pNum || !pNum->IsInteger()) return false; const int raw_value = pNum->GetInteger(); @@ -40,12 +42,13 @@ bool IsValidNumericDictionaryValue(const CPDF_Dictionary* pDict, bool IsLinearizedHeaderValid(const CPDF_LinearizedHeader* header, FX_FILESIZE document_size) { - ASSERT(header); + DCHECK(header); return header->GetFileSize() == document_size && header->GetFirstPageNo() < kMaxInt && header->GetFirstPageNo() < header->GetPageCount() && header->GetMainXRefTableFirstEntryOffset() < document_size && header->GetFirstPageEndOffset() < document_size && + header->GetFirstPageObjNum() < CPDF_Parser::kMaxObjectNumber && header->GetLastXRefOffset() < document_size && header->GetHintStart() < document_size; } @@ -71,7 +74,7 @@ std::unique_ptr<CPDF_LinearizedHeader> CPDF_LinearizedHeader::Parse( } // Move parser to the start of the xref table for the documents first page. // (skpping endobj keyword) - if (parser->GetNextWord(nullptr) != "endobj") + if (parser->GetNextWord().word != "endobj") return nullptr; auto result = pdfium::WrapUnique( @@ -92,7 +95,7 @@ CPDF_LinearizedHeader::CPDF_LinearizedHeader(const CPDF_Dictionary* pDict, m_szFirstPageEndOffset(pDict->GetIntegerFor("E")), m_FirstPageObjNum(pDict->GetIntegerFor("O")), m_szLastXRefOffset(szLastXRefOffset) { - const CPDF_Array* pHintStreamRange = pDict->GetArrayFor("H"); + RetainPtr<const CPDF_Array> pHintStreamRange = pDict->GetArrayFor("H"); const size_t nHintStreamSize = pHintStreamRange ? pHintStreamRange->size() : 0; if (nHintStreamSize == 2 || nHintStreamSize == 4) { @@ -103,7 +106,7 @@ CPDF_LinearizedHeader::CPDF_LinearizedHeader(const CPDF_Dictionary* pDict, } } -CPDF_LinearizedHeader::~CPDF_LinearizedHeader() {} +CPDF_LinearizedHeader::~CPDF_LinearizedHeader() = default; bool CPDF_LinearizedHeader::HasHintTable() const { return GetPageCount() > 1 && GetHintStart() > 0 && GetHintLength() > 0; |