diff options
author | Tom Sepez <tsepez@chromium.org> | 2024-05-11 01:58:17 +0000 |
---|---|---|
committer | Pdfium LUCI CQ <pdfium-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-05-11 01:58:17 +0000 |
commit | d48c76610264bf237477737d3780caa7056f7d1b (patch) | |
tree | 45ae5004b32704da8df258b109aca60366d61f23 | |
parent | f53b3a3469d7bc7cb29f190636b4461a7a077cb2 (diff) | |
download | pdfium-d48c76610264bf237477737d3780caa7056f7d1b.tar.gz |
Resolve unsafe buffer usage in cpdf_aaction.cpp and cpdf_action.cpp
Conversion to std::array<> solves the issues.
Bug: pdfium:2155
Change-Id: Ib23bd2a901ec5e509b19feb3ec2b250cc2bd706c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/119011
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r-- | core/fpdfdoc/cpdf_aaction.cpp | 56 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_action.cpp | 31 |
2 files changed, 46 insertions, 41 deletions
diff --git a/core/fpdfdoc/cpdf_aaction.cpp b/core/fpdfdoc/cpdf_aaction.cpp index c50171e21..fa8681410 100644 --- a/core/fpdfdoc/cpdf_aaction.cpp +++ b/core/fpdfdoc/cpdf_aaction.cpp @@ -4,13 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#if defined(UNSAFE_BUFFERS_BUILD) -// TODO(crbug.com/pdfium/2153): resolve buffer safety issues. -#pragma allow_unsafe_buffers -#endif - #include "core/fpdfdoc/cpdf_aaction.h" +#include <array> #include <iterator> #include <utility> @@ -18,34 +14,32 @@ namespace { -constexpr const char* kAATypes[] = { - "E", // kCursorEnter - "X", // kCursorExit - "D", // kButtonDown - "U", // kButtonUp - "Fo", // kGetFocus - "Bl", // kLoseFocus - "PO", // kPageOpen - "PC", // kPageClose - "PV", // kPageVisible - "PI", // kPageInvisible - "O", // kOpenPage - "C", // kClosePage - "K", // kKeyStroke - "F", // kFormat - "V", // kValidate - "C", // kCalculate - "WC", // kCloseDocument - "WS", // kSaveDocument - "DS", // kDocumentSaved - "WP", // kPrintDocument - "DP", // kDocumentPrinted -}; - // |kAATypes| should have one less element than enum AActionType due to // |kDocumentOpen|, which is an artificial type. -static_assert(std::size(kAATypes) == CPDF_AAction::kNumberOfActions - 1, - "kAATypes count mismatch"); +constexpr const std::array<const char*, CPDF_AAction::kNumberOfActions - 1> + kAATypes = {{ + "E", // kCursorEnter + "X", // kCursorExit + "D", // kButtonDown + "U", // kButtonUp + "Fo", // kGetFocus + "Bl", // kLoseFocus + "PO", // kPageOpen + "PC", // kPageClose + "PV", // kPageVisible + "PI", // kPageInvisible + "O", // kOpenPage + "C", // kClosePage + "K", // kKeyStroke + "F", // kFormat + "V", // kValidate + "C", // kCalculate + "WC", // kCloseDocument + "WS", // kSaveDocument + "DS", // kDocumentSaved + "WP", // kPrintDocument + "DP", // kDocumentPrinted + }}; } // namespace diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp index 66b735ecb..1f5f0d313 100644 --- a/core/fpdfdoc/cpdf_action.cpp +++ b/core/fpdfdoc/cpdf_action.cpp @@ -4,13 +4,9 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#if defined(UNSAFE_BUFFERS_BUILD) -// TODO(crbug.com/pdfium/2153): resolve buffer safety issues. -#pragma allow_unsafe_buffers -#endif - #include "core/fpdfdoc/cpdf_action.h" +#include <array> #include <iterator> #include <utility> @@ -24,11 +20,26 @@ namespace { -const char* const kActionTypeStrings[] = { - "GoTo", "GoToR", "GoToE", "Launch", "Thread", - "URI", "Sound", "Movie", "Hide", "Named", - "SubmitForm", "ResetForm", "ImportData", "JavaScript", "SetOCGState", - "Rendition", "Trans", "GoTo3DView"}; +const std::array<const char*, 18> kActionTypeStrings = {{ + "GoTo", + "GoToR", + "GoToE", + "Launch", + "Thread", + "URI", + "Sound", + "Movie", + "Hide", + "Named", + "SubmitForm", + "ResetForm", + "ImportData", + "JavaScript", + "SetOCGState", + "Rendition", + "Trans", + "GoTo3DView", +}}; } // namespace |