WebKit Bugzilla
Attachment 340064 Details for
Bug 185496
: Fix some -Wstring-op-truncation warnings
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185496-20180509220215.patch (text/plain), 4.49 KB, created by
Michael Catanzaro
on 2018-05-09 20:02:16 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Michael Catanzaro
Created:
2018-05-09 20:02:16 PDT
Size:
4.49 KB
patch
obsolete
>Subversion Revision: 231625 >diff --git a/Source/ThirdParty/ChangeLog b/Source/ThirdParty/ChangeLog >index 8548df5e9b40fdded58295209e616942d5de550a..37524f3e01a6dac4f36ce481388c3184cd924042 100644 >--- a/Source/ThirdParty/ChangeLog >+++ b/Source/ThirdParty/ChangeLog >@@ -1,3 +1,14 @@ >+2018-05-09 Michael Catanzaro <mcatanzaro@igalia.com> >+ >+ Fix some -Wstring-op-truncation warnings >+ https://bugs.webkit.org/show_bug.cgi?id=185496 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Disable this warning when building gtest. >+ >+ * gtest/CMakeLists.txt: >+ > 2018-05-09 Michael Catanzaro <mcatanzaro@igalia.com> > > [WPE] Build cleanly with GCC 8 and ICU 60 >diff --git a/Source/ThirdParty/gtest/CMakeLists.txt b/Source/ThirdParty/gtest/CMakeLists.txt >index 99f7fb046f9b09ad2001dca9afca7f46304f450e..dd1005fe6e57c520be97f4f8052b426f0fe0568f 100755 >--- a/Source/ThirdParty/gtest/CMakeLists.txt >+++ b/Source/ThirdParty/gtest/CMakeLists.txt >@@ -35,6 +35,7 @@ include_directories(${GTEST_INCLUDE_DIRECTORIES}) > add_definitions(-DGTEST_HAS_RTTI=0) > > WEBKIT_ADD_TARGET_CXX_FLAGS(gtest -Wno-undef >+ -Wno-stringop-truncation > -Wno-suggest-attribute=format) > > # FIXME: This works around compatibility problems in the old version of the third-pary >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 5e602effd4cc111aa632041145e9873b7a6996b9..badc6b4789c1de1f935b746d9278d3769577d6e5 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,21 @@ >+2018-05-09 Michael Catanzaro <mcatanzaro@igalia.com> >+ >+ Fix some -Wstring-op-truncation warnings >+ https://bugs.webkit.org/show_bug.cgi?id=185496 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ We have an off-by-one in the use of strncpy. The strings would not be null-terminated if >+ the input was too long. Ensure the buffers are zero-initialized so we don't need to manually >+ set the last bucket to NUL. >+ >+ * TestWebKitAPI/Tests/WTF/AtomicString.cpp: >+ (TestWebKitAPI::testAtomicStringNumber): >+ * TestWebKitAPI/Tests/WTF/WTFString.cpp: >+ (TestWebKitAPI::testStringNumberFixedPrecision): >+ (TestWebKitAPI::testStringNumberFixedWidth): >+ (TestWebKitAPI::testStringNumber): >+ > 2018-05-09 Chris Dumez <cdumez@apple.com> > > Unreviewed Windows build fix after r231622. >diff --git a/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp b/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp >index 1d4ae4eb14955b823e86cbccb6fdea1e6eb44b3c..08b1f805215361b1c3f2add92b47cae069d97822 100644 >--- a/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp >+++ b/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp >@@ -63,8 +63,8 @@ TEST(WTF, AtomicStringExistingHash) > > static inline const char* testAtomicStringNumber(double number) > { >- static char testBuffer[100]; >- std::strncpy(testBuffer, AtomicString::number(number).string().utf8().data(), 100); >+ static char testBuffer[100] = { }; >+ std::strncpy(testBuffer, AtomicString::number(number).string().utf8().data(), 99); > return testBuffer; > } > >diff --git a/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp b/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp >index 4ecfe2ffe6cd31d958348a0615a0d0e5155cf6cd..7f66c181b9dbfea144a09be134d74486b421fd60 100644 >--- a/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp >+++ b/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp >@@ -67,8 +67,8 @@ TEST(WTF, StringASCII) > > static inline const char* testStringNumberFixedPrecision(double number) > { >- static char testBuffer[100]; >- std::strncpy(testBuffer, String::number(number).utf8().data(), 100); >+ static char testBuffer[100] = { }; >+ std::strncpy(testBuffer, String::number(number).utf8().data(), 99); > return testBuffer; > } > >@@ -116,8 +116,8 @@ TEST(WTF, StringNumberFixedPrecision) > > static inline const char* testStringNumberFixedWidth(double number) > { >- static char testBuffer[100]; >- std::strncpy(testBuffer, String::numberToStringFixedWidth(number, 6).utf8().data(), 100); >+ static char testBuffer[100] = { }; >+ std::strncpy(testBuffer, String::numberToStringFixedWidth(number, 6).utf8().data(), 99); > return testBuffer; > } > >@@ -165,8 +165,8 @@ TEST(WTF, StringNumberFixedWidth) > > static inline const char* testStringNumber(double number) > { >- static char testBuffer[100]; >- std::strncpy(testBuffer, String::numberToStringECMAScript(number).utf8().data(), 100); >+ static char testBuffer[100] = { }; >+ std::strncpy(testBuffer, String::numberToStringECMAScript(number).utf8().data(), 99); > return testBuffer; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185496
: 340064