From bacf75eeeb5d89fe60b2c77584350ca1b1432bd5 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 27 Sep 2017 10:58:52 -0400 Subject: Replace FX_SAFE_STRSIZE with FX_SAFE_SIZE_T BUG=pdfium:828 Change-Id: If9560338c456b28f968e743a90a3629791d87df0 Reviewed-on: https://pdfium-review.googlesource.com/14832 Commit-Queue: Ryan Harrison Reviewed-by: dsinclair Reviewed-by: Henrique Nakashima --- core/fxcrt/bytestring.cpp | 4 ++-- core/fxcrt/cfx_binarybuf.cpp | 2 +- core/fxcrt/fx_safe_types.h | 1 - core/fxcrt/widestring.cpp | 4 ++-- core/fxcrt/xml/cfx_xmlsyntaxparser.cpp | 2 +- testing/libfuzzer/pdf_fm2js_fuzzer.cc | 2 +- testing/libfuzzer/pdf_xml_fuzzer.cc | 2 +- 7 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp index bd195dda1d..3079eb7b72 100644 --- a/core/fxcrt/bytestring.cpp +++ b/core/fxcrt/bytestring.cpp @@ -125,7 +125,7 @@ ByteString::ByteString(const ByteStringView& stringSrc) { } ByteString::ByteString(const ByteStringView& str1, const ByteStringView& str2) { - FX_SAFE_STRSIZE nSafeLen = str1.GetLength(); + FX_SAFE_SIZE_T nSafeLen = str1.GetLength(); nSafeLen += str2.GetLength(); size_t nNewLen = nSafeLen.ValueOrDie(); @@ -139,7 +139,7 @@ ByteString::ByteString(const ByteStringView& str1, const ByteStringView& str2) { } ByteString::ByteString(const std::initializer_list& list) { - FX_SAFE_STRSIZE nSafeLen = 0; + FX_SAFE_SIZE_T nSafeLen = 0; for (const auto& item : list) nSafeLen += item.GetLength(); diff --git a/core/fxcrt/cfx_binarybuf.cpp b/core/fxcrt/cfx_binarybuf.cpp index d1bd05385d..3673fa58d4 100644 --- a/core/fxcrt/cfx_binarybuf.cpp +++ b/core/fxcrt/cfx_binarybuf.cpp @@ -49,7 +49,7 @@ void CFX_BinaryBuf::EstimateSize(size_t size, size_t step) { } void CFX_BinaryBuf::ExpandBuf(size_t add_size) { - FX_SAFE_STRSIZE new_size = m_DataSize; + FX_SAFE_SIZE_T new_size = m_DataSize; new_size += add_size; if (m_AllocSize >= new_size.ValueOrDie()) return; diff --git a/core/fxcrt/fx_safe_types.h b/core/fxcrt/fx_safe_types.h index aae608096f..51eb89cf76 100644 --- a/core/fxcrt/fx_safe_types.h +++ b/core/fxcrt/fx_safe_types.h @@ -14,6 +14,5 @@ typedef pdfium::base::CheckedNumeric FX_SAFE_UINT32; typedef pdfium::base::CheckedNumeric FX_SAFE_INT32; typedef pdfium::base::CheckedNumeric FX_SAFE_SIZE_T; typedef pdfium::base::CheckedNumeric FX_SAFE_FILESIZE; -typedef pdfium::base::CheckedNumeric FX_SAFE_STRSIZE; #endif // CORE_FXCRT_FX_SAFE_TYPES_H_ diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp index a4632ee9db..b9d6dc2080 100644 --- a/core/fxcrt/widestring.cpp +++ b/core/fxcrt/widestring.cpp @@ -314,7 +314,7 @@ WideString::WideString(const WideStringView& stringSrc) { } WideString::WideString(const WideStringView& str1, const WideStringView& str2) { - FX_SAFE_STRSIZE nSafeLen = str1.GetLength(); + FX_SAFE_SIZE_T nSafeLen = str1.GetLength(); nSafeLen += str2.GetLength(); size_t nNewLen = nSafeLen.ValueOrDie(); @@ -328,7 +328,7 @@ WideString::WideString(const WideStringView& str1, const WideStringView& str2) { } WideString::WideString(const std::initializer_list& list) { - FX_SAFE_STRSIZE nSafeLen = 0; + FX_SAFE_SIZE_T nSafeLen = 0; for (const auto& item : list) nSafeLen += item.GetLength(); diff --git a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp index 2d1d3d7a08..d72e7afa1d 100644 --- a/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp +++ b/core/fxcrt/xml/cfx_xmlsyntaxparser.cpp @@ -106,7 +106,7 @@ CFX_XMLSyntaxParser::CFX_XMLSyntaxParser( pdfium::base::checked_cast(m_pStream->GetLength())); m_iCurrentPos = m_pStream->GetBOMLength(); - FX_SAFE_STRSIZE alloc_size_safe = m_iXMLPlaneSize; + FX_SAFE_SIZE_T alloc_size_safe = m_iXMLPlaneSize; alloc_size_safe += 1; // For NUL. if (!alloc_size_safe.IsValid() || alloc_size_safe.ValueOrDie() <= 0) { m_syntaxParserResult = FX_XmlSyntaxResult::Error; diff --git a/testing/libfuzzer/pdf_fm2js_fuzzer.cc b/testing/libfuzzer/pdf_fm2js_fuzzer.cc index 438d1025ad..c93804a92e 100644 --- a/testing/libfuzzer/pdf_fm2js_fuzzer.cc +++ b/testing/libfuzzer/pdf_fm2js_fuzzer.cc @@ -11,7 +11,7 @@ #include "xfa/fxfa/fm2js/cxfa_fm2jscontext.h" extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - FX_SAFE_STRSIZE safe_size = size; + FX_SAFE_SIZE_T safe_size = size; if (!safe_size.IsValid()) return 0; diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc index 0c3cf4fb3f..d8010f90f8 100644 --- a/testing/libfuzzer/pdf_xml_fuzzer.cc +++ b/testing/libfuzzer/pdf_xml_fuzzer.cc @@ -46,7 +46,7 @@ CFX_XMLNode* XFA_FDEExtension_GetDocumentNode( } // namespace extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - FX_SAFE_STRSIZE safe_size = size; + FX_SAFE_SIZE_T safe_size = size; if (!safe_size.IsValid()) return 0; -- cgit v1.2.3