Title: [170513] trunk/Source/WebCore
Revision
170513
Author
[email protected]
Date
2014-06-26 18:10:48 -0700 (Thu, 26 Jun 2014)

Log Message

[Win] Always NULL-terminate the string in createUTF8String()
<http://webkit.org/b/134353>
<rdar://problem/17471783>

Reviewed by Brent Fulgham.

* plugins/PluginView.cpp:
(WebCore::createUTF8String): Pull out CString length into local
variable.  Switch to use memcpy.  Always NULL-terminate the
string.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (170512 => 170513)


--- trunk/Source/WebCore/ChangeLog	2014-06-27 00:28:14 UTC (rev 170512)
+++ trunk/Source/WebCore/ChangeLog	2014-06-27 01:10:48 UTC (rev 170513)
@@ -1,3 +1,16 @@
+2014-06-26  David Kilzer  <[email protected]>
+
+        [Win] Always NULL-terminate the string in createUTF8String()
+        <http://webkit.org/b/134353>
+        <rdar://problem/17471783>
+
+        Reviewed by Brent Fulgham.
+
+        * plugins/PluginView.cpp:
+        (WebCore::createUTF8String): Pull out CString length into local
+        variable.  Switch to use memcpy.  Always NULL-terminate the
+        string.
+
 2014-06-26  Jer Noble  <[email protected]>
 
         [MSE][Mac] Crash in WebCore::MediaPlayerPrivateMediaSourceAVFObjC::buffered const + 13

Modified: trunk/Source/WebCore/plugins/PluginView.cpp (170512 => 170513)


--- trunk/Source/WebCore/plugins/PluginView.cpp	2014-06-27 00:28:14 UTC (rev 170512)
+++ trunk/Source/WebCore/plugins/PluginView.cpp	2014-06-27 01:10:48 UTC (rev 170513)
@@ -409,9 +409,11 @@
 static char* createUTF8String(const String& str)
 {
     CString cstr = str.utf8();
-    char* result = reinterpret_cast<char*>(fastMalloc(cstr.length() + 1));
+    const size_t cstrLength = cstr.length();
+    char* result = reinterpret_cast<char*>(fastMalloc(cstrLength + 1));
 
-    strncpy(result, cstr.data(), cstr.length() + 1);
+    memcpy(result, cstr.data(), cstrLength);
+    result[cstrLength] = '\0';
 
     return result;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to