aboutsummaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_edittext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/fpdf_edittext.cpp')
-rw-r--r--fpdfsdk/fpdf_edittext.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/fpdfsdk/fpdf_edittext.cpp b/fpdfsdk/fpdf_edittext.cpp
index e9595a487..04d035a27 100644
--- a/fpdfsdk/fpdf_edittext.cpp
+++ b/fpdfsdk/fpdf_edittext.cpp
@@ -2,11 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#if defined(UNSAFE_BUFFERS_BUILD)
-// TODO(crbug.com/pdfium/2153): resolve buffer safety issues.
-#pragma allow_unsafe_buffers
-#endif
-
#include <map>
#include <memory>
#include <sstream>
@@ -34,6 +29,7 @@
#include "core/fpdftext/cpdf_textpage.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
+#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/containers/contains.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_memcpy_wrappers.h"
@@ -621,7 +617,8 @@ FPDFText_SetCharcodes(FPDF_PAGEOBJECT text_object,
ByteString byte_text;
if (charcodes) {
for (size_t i = 0; i < count; ++i) {
- pTextObj->GetFont()->AppendChar(&byte_text, charcodes[i]);
+ // TODO(crbug.com/pdfium/2155): investigate safety issues.
+ pTextObj->GetFont()->AppendChar(&byte_text, UNSAFE_BUFFERS(charcodes[i]));
}
}
pTextObj->SetText(byte_text);
@@ -638,8 +635,8 @@ FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document,
(font_type != FPDF_FONT_TYPE1 && font_type != FPDF_FONT_TRUETYPE)) {
return nullptr;
}
-
- auto span = pdfium::make_span(data, size);
+ // SAFETY: required from caller.
+ auto span = UNSAFE_BUFFERS(pdfium::make_span(data, size));
auto pFont = std::make_unique<CFX_Font>();
// TODO(npm): Maybe use FT_Get_X11_Font_Format to check format? Otherwise, we
@@ -678,8 +675,8 @@ FPDFText_LoadCidType2Font(FPDF_DOCUMENT document,
cid_to_gid_map_data_size == 0) {
return nullptr;
}
-
- auto font_span = pdfium::make_span(font_data, font_data_size);
+ // SAFETY: required from caller.
+ auto font_span = UNSAFE_BUFFERS(pdfium::make_span(font_data, font_data_size));
auto font = std::make_unique<CFX_Font>();
// TODO(thestig): Consider checking the font format. See similar comment in
@@ -727,7 +724,9 @@ FPDFTextObj_GetText(FPDF_PAGEOBJECT text_object,
return 0;
WideString text = pTextPage->GetTextByObject(pTextObj);
- return Utf16EncodeMaybeCopyAndReturnLength(text, buffer, length);
+ // SAFETY: required from caller.
+ return UNSAFE_BUFFERS(
+ Utf16EncodeMaybeCopyAndReturnLength(text, buffer, length));
}
FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV