From 9fe6f3ad47ca099efe5ae18aabfae6594a1e0329 Mon Sep 17 00:00:00 2001 From: thestig Date: Fri, 12 Aug 2016 20:00:32 -0700 Subject: Avoid an undefined shift in ReadPageHintTable(). Even 39 bits is very generous for the number of bits needed to represent the greatest number of shared object references. BUG=637119 Review-Url: https://codereview.chromium.org/2242723002 --- core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp b/core/fpdfapi/fpdf_parser/cpdf_hint_tables.cpp index 63a64a3026..7a3fbacfb3 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) -- cgit v1.2.3