Mark unsafe_buffers regions in core/fpdfapi/font files.
Bug: pdfium:2154
Change-Id: Idd5e91bf8f1141820d9cc916b2889ffd5893e2eb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/119470
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfapi/font/cpdf_fontencoding.cpp b/core/fpdfapi/font/cpdf_fontencoding.cpp
index dcc614a..f5a5dc3 100644
--- a/core/fpdfapi/font/cpdf_fontencoding.cpp
+++ b/core/fpdfapi/font/cpdf_fontencoding.cpp
@@ -4,11 +4,6 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#if defined(UNSAFE_BUFFERS_BUILD)
-// TODO(crbug.com/pdfium/2154): resolve buffer safety issues.
-#pragma allow_unsafe_buffers
-#endif
-
#include "core/fpdfapi/font/cpdf_fontencoding.h"
#include <iterator>
@@ -20,6 +15,7 @@
#include "core/fpdfapi/parser/cpdf_name.h"
#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/fpdf_parser_decode.h"
+#include "core/fxcrt/compiler_specific.h"
#include "core/fxge/fx_font.h"
#include "core/fxge/fx_fontencoding.h"
@@ -1764,7 +1760,7 @@
}
wchar_t UnicodeFromAppleRomanCharCode(uint8_t charcode) {
- return kMacRomanEncoding[charcode];
+ return UNSAFE_TODO(kMacRomanEncoding[charcode]);
}
pdfium::span<const uint16_t> UnicodesForPredefinedCharSet(
@@ -1806,19 +1802,19 @@
}
switch (encoding) {
case FontEncoding::kWinAnsi:
- return kAdobeWinAnsiEncodingNames[charcode];
+ return UNSAFE_TODO(kAdobeWinAnsiEncodingNames[charcode]);
case FontEncoding::kMacRoman:
- return kMacRomanEncodingNames[charcode];
+ return UNSAFE_TODO(kMacRomanEncodingNames[charcode]);
case FontEncoding::kMacExpert:
- return kMacExpertEncodingNames[charcode];
+ return UNSAFE_TODO(kMacExpertEncodingNames[charcode]);
case FontEncoding::kStandard:
- return kStandardEncodingNames[charcode];
+ return UNSAFE_TODO(kStandardEncodingNames[charcode]);
case FontEncoding::kAdobeSymbol:
- return kAdobeSymbolEncodingNames[charcode];
+ return UNSAFE_TODO(kAdobeSymbolEncodingNames[charcode]);
case FontEncoding::kZapfDingbats:
- return kZapfEncodingNames[charcode];
+ return UNSAFE_TODO(kZapfEncodingNames[charcode]);
case FontEncoding::kPdfDoc:
- return kPDFDocEncodingNames[charcode];
+ return UNSAFE_TODO(kPDFDocEncodingNames[charcode]);
default:
return nullptr;
}
diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp
index 7e345ce..8703bc8 100644
--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
+++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
@@ -4,11 +4,6 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#if defined(UNSAFE_BUFFERS_BUILD)
-// TODO(crbug.com/pdfium/2154): resolve buffer safety issues.
-#pragma allow_unsafe_buffers
-#endif
-
#include "core/fpdfapi/font/cpdf_truetypefont.h"
#include <algorithm>
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp
index fe99019..6e92568 100644
--- a/core/fpdfapi/font/cpdf_type1font.cpp
+++ b/core/fpdfapi/font/cpdf_type1font.cpp
@@ -4,11 +4,6 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#if defined(UNSAFE_BUFFERS_BUILD)
-// TODO(crbug.com/pdfium/2154): resolve buffer safety issues.
-#pragma allow_unsafe_buffers
-#endif
-
#include "core/fpdfapi/font/cpdf_type1font.h"
#include <algorithm>
@@ -17,6 +12,7 @@
#include "build/build_config.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/fx_memcpy_wrappers.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/span_util.h"
@@ -156,7 +152,7 @@
for (uint32_t charcode = 0; charcode < kInternalTableSize; charcode++) {
const uint8_t prefix[4] = {0x00, 0xf0, 0xf1, 0xf2};
for (int j = 0; j < 4; j++) {
- uint16_t unicode = prefix[j] * 256 + charcode;
+ uint16_t unicode = UNSAFE_TODO(prefix[j]) * 256 + charcode;
m_GlyphIndex[charcode] = face->GetCharIndex(unicode);
#if BUILDFLAG(IS_APPLE)
CalcExtGID(charcode);