diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-02-04 10:48:28 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-02-04 10:48:28 -0800 |
commit | 53476d6956781ceb252e1ae5e01f83a48bcb4908 (patch) | |
tree | 9310dbde273217a0de7e5165c585b081b046bf1c /core/src | |
parent | d2501393eb0c18b5e73506658cd8e8ae0c4ea456 (diff) | |
download | pdfium-53476d6956781ceb252e1ae5e01f83a48bcb4908.tar.xz |
Merge to XFA: Prevent base::CheckedNumeric from leaking outside of pdfium.
Original review URL: https://codereview.chromium.org/896023003
TBR=jam@chromium.org
Review URL: https://codereview.chromium.org/897023005
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/fdrm/crypto/fx_crypt.cpp | 2 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp | 6 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 2 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp | 2 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_link.cpp | 2 | ||||
-rw-r--r-- | core/src/fxcrt/extension.h | 2 | ||||
-rw-r--r-- | core/src/fxcrt/fx_safe_types.h | 17 |
7 files changed, 30 insertions, 3 deletions
diff --git a/core/src/fdrm/crypto/fx_crypt.cpp b/core/src/fdrm/crypto/fx_crypt.cpp index 8128f91f89..1fbba993d2 100644 --- a/core/src/fdrm/crypto/fx_crypt.cpp +++ b/core/src/fdrm/crypto/fx_crypt.cpp @@ -6,6 +6,8 @@ #include "../../../include/fxcrt/fx_basic.h" #include "../../../include/fdrm/fx_crypt.h" +#include "../../../src/fxcrt/fx_safe_types.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp index 649bd54a33..4ba0489ee4 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_func.cpp @@ -4,10 +4,14 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +#include <limits.h> + #include "../../../include/fpdfapi/fpdf_page.h" #include "../../../include/fpdfapi/fpdf_module.h" +#include "../../../src/fxcrt/fx_safe_types.h" +#include "../../../third_party/numerics/safe_conversions_impl.h" #include "pageint.h" -#include <limits.h> + class CPDF_PSEngine; typedef enum {PSOP_ADD, PSOP_SUB, PSOP_MUL, PSOP_DIV, PSOP_IDIV, PSOP_MOD, PSOP_NEG, PSOP_ABS, PSOP_CEILING, PSOP_FLOOR, PSOP_ROUND, PSOP_TRUNCATE, diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index 6ff200c085..eaecb0fe9f 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -7,7 +7,7 @@ #include "../../../include/fpdfapi/fpdf_parser.h" #include "../../../include/fpdfapi/fpdf_module.h" #include "../../../include/fpdfapi/fpdf_page.h" -#include "../../../../third_party/numerics/safe_math.h" +#include "../../../src/fxcrt/fx_safe_types.h" #include "../fpdf_page/pageint.h" #include <utility> #include <vector> diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp index 1637655e68..f938628f55 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp @@ -9,9 +9,9 @@ #include "../../../include/fpdfapi/fpdf_module.h" #include "../../../include/fpdfapi/fpdf_render.h" #include "../../../include/fpdfapi/fpdf_pageobj.h" +#include "../../../src/fxcrt/fx_safe_types.h" #include "../fpdf_page/pageint.h" #include "render_int.h" -#include "../../../../third_party/numerics/safe_math.h" static unsigned int _GetBits8(FX_LPCBYTE pData, int bitpos, int nbits) { diff --git a/core/src/fpdfdoc/doc_link.cpp b/core/src/fpdfdoc/doc_link.cpp index 0d1b98e7b7..c27333e08b 100644 --- a/core/src/fpdfdoc/doc_link.cpp +++ b/core/src/fpdfdoc/doc_link.cpp @@ -5,6 +5,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #include "../../include/fpdfdoc/fpdf_doc.h" +#include "../../src/fxcrt/fx_safe_types.h" + CPDF_LinkList::~CPDF_LinkList() { FX_POSITION pos = m_PageMap.GetStartPosition(); diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 05aad67e40..bf60292a4d 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -7,6 +7,8 @@ #ifndef _FXCRT_EXTENSION_IMP_ #define _FXCRT_EXTENSION_IMP_ +#include "fx_safe_types.h" + class IFXCRT_FileAccess { public: diff --git a/core/src/fxcrt/fx_safe_types.h b/core/src/fxcrt/fx_safe_types.h new file mode 100644 index 0000000000..794e1f19dc --- /dev/null +++ b/core/src/fxcrt/fx_safe_types.h @@ -0,0 +1,17 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef FX_SAFE_TYPES_H_ +#define FX_SAFE_TYPES_H_ + +#include <stdlib.h> // For size_t. + +#include "../../../third_party/numerics/safe_math.h" + +typedef base::CheckedNumeric<FX_DWORD> FX_SAFE_DWORD; +typedef base::CheckedNumeric<FX_INT32> FX_SAFE_INT32; +typedef base::CheckedNumeric<size_t> FX_SAFE_SIZE_T; +typedef base::CheckedNumeric<FX_FILESIZE> FX_SAFE_FILESIZE; + +#endif // FX_SAFE_TYPES_H_ |