Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(809)

Unified Diff: core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp

Issue 2242723002: Avoid an undefined shift in ReadPageHintTable(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: constant, comment Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
index 63a64a302691f5b8ca63cdf1b1f674cd437d8c4a..7a3fbacfb3ae91b71b9ca87da99b2edcb44ecb69 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp
@@ -109,6 +109,12 @@ FX_BOOL CPDF_HintTables::ReadPageHintTable(CFX_BitStream* hStream) {
// Item 13: Skip Item 13 which has 16 bits.
hStream->SkipBits(16);
+ // The maximum number of bits allowed to represent the greatest number of
+ // shared object references. 2^39 should be more than enough.
+ constexpr uint32_t kMaxSharedObjBits = 39;
+ if (dwSharedObjBits > kMaxSharedObjBits)
+ return FALSE;
+
CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectBy("N");
int nPages = pPageNum ? pPageNum->GetInteger() : 0;
if (nPages < 1)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698