| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fpdfapi/fpdf_parser/cpdf_hint_tables.h" | 7 #include "core/fpdfapi/fpdf_parser/cpdf_hint_tables.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_data_avail.h" |
| 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 // Item 12: The number of bits needed to represent the numerator of | 103 // Item 12: The number of bits needed to represent the numerator of |
| 104 // the fractional position for each shared object reference. For each | 104 // the fractional position for each shared object reference. For each |
| 105 // shared object referenced from a page, there is an indication of | 105 // shared object referenced from a page, there is an indication of |
| 106 // where in the page's content stream the object is first referenced. | 106 // where in the page's content stream the object is first referenced. |
| 107 uint32_t dwSharedNumeratorBits = hStream->GetBits(16); | 107 uint32_t dwSharedNumeratorBits = hStream->GetBits(16); |
| 108 | 108 |
| 109 // Item 13: Skip Item 13 which has 16 bits. | 109 // Item 13: Skip Item 13 which has 16 bits. |
| 110 hStream->SkipBits(16); | 110 hStream->SkipBits(16); |
| 111 | 111 |
| 112 // The maximum number of bits allowed to represent the greatest number of |
| 113 // shared object references. 2^39 should be more than enough. |
| 114 constexpr uint32_t kMaxSharedObjBits = 39; |
| 115 if (dwSharedObjBits > kMaxSharedObjBits) |
| 116 return FALSE; |
| 117 |
| 112 CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectBy("N"); | 118 CPDF_Object* pPageNum = m_pLinearizedDict->GetDirectObjectBy("N"); |
| 113 int nPages = pPageNum ? pPageNum->GetInteger() : 0; | 119 int nPages = pPageNum ? pPageNum->GetInteger() : 0; |
| 114 if (nPages < 1) | 120 if (nPages < 1) |
| 115 return FALSE; | 121 return FALSE; |
| 116 | 122 |
| 117 FX_SAFE_UINT32 required_bits = dwDeltaObjectsBits; | 123 FX_SAFE_UINT32 required_bits = dwDeltaObjectsBits; |
| 118 required_bits *= pdfium::base::checked_cast<uint32_t>(nPages); | 124 required_bits *= pdfium::base::checked_cast<uint32_t>(nPages); |
| 119 if (!CanReadFromBitStream(hStream, required_bits)) | 125 if (!CanReadFromBitStream(hStream, required_bits)) |
| 120 return FALSE; | 126 return FALSE; |
| 121 | 127 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); | 485 CPDF_Array* pRange = m_pLinearizedDict->GetArrayBy("H"); |
| 480 if (!pRange) | 486 if (!pRange) |
| 481 return -1; | 487 return -1; |
| 482 | 488 |
| 483 CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(1); | 489 CPDF_Object* pStreamLen = pRange->GetDirectObjectAt(1); |
| 484 if (!pStreamLen) | 490 if (!pStreamLen) |
| 485 return -1; | 491 return -1; |
| 486 | 492 |
| 487 return pStreamLen->GetInteger(); | 493 return pStreamLen->GetInteger(); |
| 488 } | 494 } |
| OLD | NEW |