7#include "core/fpdfapi/parser/cpdf_linearized_header.h"
13#include "core/fpdfapi/parser/cpdf_array.h"
14#include "core/fpdfapi/parser/cpdf_dictionary.h"
15#include "core/fpdfapi/parser/cpdf_number.h"
16#include "core/fpdfapi/parser/cpdf_parser.h"
17#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
18#include "core/fxcrt/check.h"
19#include "core/fxcrt/fx_safe_types.h"
20#include "core/fxcrt/ptr_util.h"
25constexpr size_t kMaxInt =
static_cast<size_t>(
std::numeric_limits<
int>::max());
31 bool must_exist =
true) {
34 RetainPtr<
const CPDF_Number> pNum = pDict->GetNumberFor(key);
35 if (!pNum || !pNum->IsInteger())
37 const int raw_value = pNum->GetInteger();
38 if (!
pdfium::IsValueInRangeForNumericType<T>(raw_value)) {
41 return static_cast<T>(raw_value) >= min_value;
64 const auto pDict = ToDictionary(
67 if (!pDict || !pDict->KeyExist(
"Linearized") ||
68 !IsValidNumericDictionaryValue<
FX_FILESIZE>(pDict.Get(),
"L", 1) ||
69 !IsValidNumericDictionaryValue<uint32_t>(pDict.Get(),
"P", 0,
false) ||
70 !IsValidNumericDictionaryValue<
FX_FILESIZE>(pDict.Get(),
"T", 1) ||
71 !IsValidNumericDictionaryValue<uint32_t>(pDict.Get(),
"N", 1) ||
72 !IsValidNumericDictionaryValue<
FX_FILESIZE>(pDict.Get(),
"E", 1) ||
73 !IsValidNumericDictionaryValue<uint32_t>(pDict.Get(),
"O", 1)) {
81 auto result =
pdfium::WrapUnique(
98 m_szLastXRefOffset(szLastXRefOffset) {
100 const size_t nHintStreamSize =
101 pHintStreamRange ? pHintStreamRange->size() : 0;
102 if (nHintStreamSize == 2 || nHintStreamSize == 4) {
103 m_szHintStart =
std::max(pHintStreamRange->GetIntegerAt(0), 0);
104 const FX_SAFE_UINT32 safe_hint_length = pHintStreamRange->GetIntegerAt(1);
105 if (safe_hint_length.IsValid())
106 m_HintLength = safe_hint_length.ValueOrDie();
fxcrt::ByteString ByteString
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
bool KeyExist(const ByteString &key) const
int GetIntegerFor(const ByteString &key) const
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
static constexpr uint32_t kMaxObjectNumber
RetainPtr< CPDF_Object > GetIndirectObject(CPDF_IndirectObjectHolder *pObjList, ParseType parse_type)
FX_FILESIZE GetPos() const
FX_FILESIZE GetDocumentSize() const
void SetPos(FX_FILESIZE pos)
pdfium::CheckedNumeric< uint32_t > FX_SAFE_UINT32