summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/fpdfapi/parser/cpdf_linearized_header.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_linearized_header.cpp b/core/fpdfapi/parser/cpdf_linearized_header.cpp
index 3251a5eb9f..994d69f9b6 100644
--- a/core/fpdfapi/parser/cpdf_linearized_header.cpp
+++ b/core/fpdfapi/parser/cpdf_linearized_header.cpp
@@ -7,6 +7,7 @@
#include "core/fpdfapi/parser/cpdf_linearized_header.h"
#include <algorithm>
+#include <limits>
#include <utility>
#include "core/fpdfapi/parser/cpdf_array.h"
@@ -18,6 +19,7 @@
namespace {
constexpr FX_FILESIZE kLinearizedHeaderOffset = 9;
+constexpr size_t kMaxInt = static_cast<size_t>(std::numeric_limits<int>::max());
template <class T>
bool IsValidNumericDictionaryValue(const CPDF_Dictionary* pDict,
@@ -39,6 +41,8 @@ bool IsLinearizedHeaderValid(const CPDF_LinearizedHeader* header,
FX_FILESIZE file_size) {
ASSERT(header);
return header->GetFileSize() == file_size &&
+ static_cast<int>(header->GetFirstPageNo()) >= 0 &&
+ header->GetFirstPageNo() < kMaxInt &&
header->GetMainXRefTableFirstEntryOffset() < file_size &&
header->GetPageCount() > 0 &&
header->GetFirstPageEndOffset() < file_size &&