Title: [231682] releases/WebKitGTK/webkit-2.20
Revision
231682
Author
[email protected]
Date
2018-05-10 18:58:58 -0700 (Thu, 10 May 2018)

Log Message

Merge r231661 - Fix some -Wstring-op-truncation warnings
https://bugs.webkit.org/show_bug.cgi?id=185496

Reviewed by Alex Christensen.

Source/ThirdParty:

Disable this warning when building gtest.

* gtest/CMakeLists.txt:

Tools:

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):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.20/Source/ThirdParty/ChangeLog (231681 => 231682)


--- releases/WebKitGTK/webkit-2.20/Source/ThirdParty/ChangeLog	2018-05-11 00:58:41 UTC (rev 231681)
+++ releases/WebKitGTK/webkit-2.20/Source/ThirdParty/ChangeLog	2018-05-11 01:58:58 UTC (rev 231682)
@@ -1,5 +1,16 @@
 2018-05-10  Michael Catanzaro  <[email protected]>
 
+        Fix some -Wstring-op-truncation warnings
+        https://bugs.webkit.org/show_bug.cgi?id=185496
+
+        Reviewed by Alex Christensen.
+
+        Disable this warning when building gtest.
+
+        * gtest/CMakeLists.txt:
+
+2018-05-10  Michael Catanzaro  <[email protected]>
+
         Unreviewed, silence a couple more build warnings on the stable branch
 
         * openvr/src/CMakeLists.txt:

Modified: releases/WebKitGTK/webkit-2.20/Source/ThirdParty/gtest/CMakeLists.txt (231681 => 231682)


--- releases/WebKitGTK/webkit-2.20/Source/ThirdParty/gtest/CMakeLists.txt	2018-05-11 00:58:41 UTC (rev 231681)
+++ releases/WebKitGTK/webkit-2.20/Source/ThirdParty/gtest/CMakeLists.txt	2018-05-11 01:58:58 UTC (rev 231682)
@@ -35,6 +35,7 @@
 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

Modified: releases/WebKitGTK/webkit-2.20/Tools/ChangeLog (231681 => 231682)


--- releases/WebKitGTK/webkit-2.20/Tools/ChangeLog	2018-05-11 00:58:41 UTC (rev 231681)
+++ releases/WebKitGTK/webkit-2.20/Tools/ChangeLog	2018-05-11 01:58:58 UTC (rev 231682)
@@ -1,5 +1,23 @@
 2018-05-10  Michael Catanzaro  <[email protected]>
 
+        Fix some -Wstring-op-truncation warnings
+        https://bugs.webkit.org/show_bug.cgi?id=185496
+
+        Reviewed by Alex Christensen.
+
+        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-10  Michael Catanzaro  <[email protected]>
+
         [WPE][STABLE] Remove unusable _javascript_ APIs
         https://bugs.webkit.org/show_bug.cgi?id=185518
 

Modified: releases/WebKitGTK/webkit-2.20/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp (231681 => 231682)


--- releases/WebKitGTK/webkit-2.20/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp	2018-05-11 00:58:41 UTC (rev 231681)
+++ releases/WebKitGTK/webkit-2.20/Tools/TestWebKitAPI/Tests/WTF/AtomicString.cpp	2018-05-11 01:58:58 UTC (rev 231682)
@@ -63,8 +63,8 @@
 
 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;
 }
 

Modified: releases/WebKitGTK/webkit-2.20/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp (231681 => 231682)


--- releases/WebKitGTK/webkit-2.20/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp	2018-05-11 00:58:41 UTC (rev 231681)
+++ releases/WebKitGTK/webkit-2.20/Tools/TestWebKitAPI/Tests/WTF/WTFString.cpp	2018-05-11 01:58:58 UTC (rev 231682)
@@ -67,8 +67,8 @@
 
 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 @@
 
 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 @@
 
 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;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to