Title: [280957] trunk/Source
Revision
280957
Author
[email protected]
Date
2021-08-11 21:35:22 -0700 (Wed, 11 Aug 2021)

Log Message

Function _os_feature_enabled_impl() expects compile-time static strings as arguments
https://bugs.webkit.org/show_bug.cgi?id=229017
<rdar://81813732>

Reviewed by Tim Horton.

There are multiple issues in the current implementation of `isFeatureFlagEnabled()`.
1. `_os_feature_enabled_impl()` expects compile-time static strings as arguments.
So we should not use `String` here.
2. As Simon Fraser pointed out, `String::characters8()` is not null terminated.

Source/WebKit:

* Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm:
(WebKit::isFeatureFlagEnabled):
* Shared/WebPreferencesDefaultValues.cpp:
(WebKit::isFeatureFlagEnabled):
* Shared/WebPreferencesDefaultValues.h:

Source/WebKitLegacy/mac:

* WebView/WebPreferencesDefaultValues.h:
* WebView/WebPreferencesDefaultValues.mm:
(WebKit::isFeatureFlagEnabled):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (280956 => 280957)


--- trunk/Source/WebKit/ChangeLog	2021-08-12 04:29:25 UTC (rev 280956)
+++ trunk/Source/WebKit/ChangeLog	2021-08-12 04:35:22 UTC (rev 280957)
@@ -1,3 +1,22 @@
+2021-08-11  Peng Liu  <[email protected]>
+
+        Function _os_feature_enabled_impl() expects compile-time static strings as arguments
+        https://bugs.webkit.org/show_bug.cgi?id=229017
+        <rdar://81813732>
+
+        Reviewed by Tim Horton.
+
+        There are multiple issues in the current implementation of `isFeatureFlagEnabled()`.
+        1. `_os_feature_enabled_impl()` expects compile-time static strings as arguments.
+        So we should not use `String` here.
+        2. As Simon Fraser pointed out, `String::characters8()` is not null terminated.
+
+        * Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm:
+        (WebKit::isFeatureFlagEnabled):
+        * Shared/WebPreferencesDefaultValues.cpp:
+        (WebKit::isFeatureFlagEnabled):
+        * Shared/WebPreferencesDefaultValues.h:
+
 2021-08-11  Jean-Yves Avenard  <[email protected]>
 
         [Monterey] WebContent process immediately crash when GPU Process is disabled

Modified: trunk/Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm (280956 => 280957)


--- trunk/Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm	2021-08-12 04:29:25 UTC (rev 280956)
+++ trunk/Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm	2021-08-12 04:35:22 UTC (rev 280957)
@@ -38,7 +38,7 @@
 namespace WebKit {
 
 // Because of <rdar://problem/60608008>, WebKit has to parse the feature flags plist file
-bool isFeatureFlagEnabled(const String& featureName, bool defaultValue)
+bool isFeatureFlagEnabled(const char* featureName, bool defaultValue)
 {
 #if HAVE(SYSTEM_FEATURE_FLAGS)
 
@@ -49,12 +49,12 @@
     }();
 
     if (isSystemWebKit)
-        return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
+        return _os_feature_enabled_impl("WebKit", featureName);
 
     return defaultValue;
 #else
     UNUSED_PARAM(defaultValue);
-    return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
+    return _os_feature_enabled_impl("WebKit", featureName);
 #endif // PLATFORM(MAC)
 
 #else

Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp (280956 => 280957)


--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp	2021-08-12 04:29:25 UTC (rev 280956)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.cpp	2021-08-12 04:35:22 UTC (rev 280957)
@@ -42,7 +42,7 @@
 namespace WebKit {
 
 #if !PLATFORM(COCOA)
-bool isFeatureFlagEnabled(const String&, bool defaultValue)
+bool isFeatureFlagEnabled(const char*, bool defaultValue)
 {
     return defaultValue;
 }

Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h (280956 => 280957)


--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h	2021-08-12 04:29:25 UTC (rev 280956)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h	2021-08-12 04:35:22 UTC (rev 280957)
@@ -35,7 +35,7 @@
 
 namespace WebKit {
 
-bool isFeatureFlagEnabled(const String&, bool defaultValue = false);
+bool isFeatureFlagEnabled(const char*, bool defaultValue = false);
 
 #if PLATFORM(IOS_FAMILY)
 bool defaultPassiveTouchListenersAsDefaultOnDocument();

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (280956 => 280957)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-08-12 04:29:25 UTC (rev 280956)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-08-12 04:35:22 UTC (rev 280957)
@@ -1,3 +1,20 @@
+2021-08-11  Peng Liu  <[email protected]>
+
+        Function _os_feature_enabled_impl() expects compile-time static strings as arguments
+        https://bugs.webkit.org/show_bug.cgi?id=229017
+        <rdar://81813732>
+
+        Reviewed by Tim Horton.
+
+        There are multiple issues in the current implementation of `isFeatureFlagEnabled()`.
+        1. `_os_feature_enabled_impl()` expects compile-time static strings as arguments.
+        So we should not use `String` here.
+        2. As Simon Fraser pointed out, `String::characters8()` is not null terminated.
+
+        * WebView/WebPreferencesDefaultValues.h:
+        * WebView/WebPreferencesDefaultValues.mm:
+        (WebKit::isFeatureFlagEnabled):
+
 2021-08-10  Peng Liu  <[email protected]>
 
         REGRESSION (r280726): [ Big Sur wk1 ] 25 imported/w3c/web-platform-tests/fetch/ failing

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h (280956 => 280957)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h	2021-08-12 04:29:25 UTC (rev 280956)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.h	2021-08-12 04:35:22 UTC (rev 280957)
@@ -36,7 +36,7 @@
 namespace WebKit {
 
 #if PLATFORM(COCOA)
-bool isFeatureFlagEnabled(const String&, bool defaultValue = false);
+bool isFeatureFlagEnabled(const char*, bool defaultValue = false);
 #endif
 
 #if HAVE(INCREMENTAL_PDF_APIS)

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm (280956 => 280957)


--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm	2021-08-12 04:29:25 UTC (rev 280956)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesDefaultValues.mm	2021-08-12 04:35:22 UTC (rev 280957)
@@ -45,7 +45,7 @@
 #if PLATFORM(COCOA)
 
 // Because of <rdar://problem/60608008>, WebKit has to parse the feature flags plist file
-bool isFeatureFlagEnabled(const String& featureName, bool defaultValue)
+bool isFeatureFlagEnabled(const char* featureName, bool defaultValue)
 {
 #if HAVE(SYSTEM_FEATURE_FLAGS)
 
@@ -53,7 +53,7 @@
     // But we need to fix <http://webkit.org/b/228926> first.
 #if PLATFORM(COCOA)
     UNUSED_PARAM(defaultValue);
-    return _os_feature_enabled_impl("WebKit", (const char*)featureName.characters8());
+    return _os_feature_enabled_impl("WebKit", featureName);
 #endif // PLATFORM(MAC)
 
 #else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to