[WPE][GTK] Ensure proper casting of data in gvariants
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Aug 2017 16:17:19 +0000 (16:17 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Aug 2017 16:17:19 +0000 (16:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175667

Patch by Jacobo Aragunde Pérez <jaragunde@igalia.com> on 2017-08-17
Reviewed by Michael Catanzaro.

Source/JavaScriptCore:

g_variant_new requires data to have the correct width for their types, using
casting if necessary. Some data of type `unsigned` were being saved to `guint64`
types without explicit casting, leading to undefined behavior in some platforms.

* inspector/remote/glib/RemoteInspectorGlib.cpp:
(Inspector::RemoteInspector::listingForInspectionTarget const):
(Inspector::RemoteInspector::listingForAutomationTarget const):
(Inspector::RemoteInspector::sendMessageToRemote):

Source/WebKit:

g_variant_builder_add requires data to have the correct width for their types, using
casting if necessary. Corrected a call where a single precision float was being put
into a double precision parameter without a cast.

* UIProcess/API/glib/WebKitWebViewSessionState.cpp:
(encodeFrameState):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220860 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/glib/WebKitWebViewSessionState.cpp

index 70481ec..7c59497 100644 (file)
@@ -1,3 +1,19 @@
+2017-08-17  Jacobo Aragunde Pérez  <jaragunde@igalia.com>
+
+        [WPE][GTK] Ensure proper casting of data in gvariants
+        https://bugs.webkit.org/show_bug.cgi?id=175667
+
+        Reviewed by Michael Catanzaro.
+
+        g_variant_new requires data to have the correct width for their types, using
+        casting if necessary. Some data of type `unsigned` were being saved to `guint64`
+        types without explicit casting, leading to undefined behavior in some platforms.
+
+        * inspector/remote/glib/RemoteInspectorGlib.cpp:
+        (Inspector::RemoteInspector::listingForInspectionTarget const):
+        (Inspector::RemoteInspector::listingForAutomationTarget const):
+        (Inspector::RemoteInspector::sendMessageToRemote):
+
 2017-08-17  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [JSC] Avoid code bloating for iteration if block does not have "break"
index bec6f70..bd387f9 100644 (file)
@@ -187,14 +187,16 @@ TargetListing RemoteInspector::listingForInspectionTarget(const RemoteInspection
         return nullptr;
 
     ASSERT(target.type() == RemoteInspectionTarget::Type::Web || target.type() == RemoteInspectionTarget::Type::JavaScript);
-    return g_variant_new("(tsssb)", target.targetIdentifier(), target.type() == RemoteInspectionTarget::Type::Web ? "Web" : "JavaScript",
+    return g_variant_new("(tsssb)", static_cast<guint64>(target.targetIdentifier()),
+        target.type() == RemoteInspectionTarget::Type::Web ? "Web" : "JavaScript",
         target.name().utf8().data(), target.type() == RemoteInspectionTarget::Type::Web ? target.url().utf8().data() : "null",
         target.hasLocalDebugger());
 }
 
 TargetListing RemoteInspector::listingForAutomationTarget(const RemoteAutomationTarget& target) const
 {
-    return g_variant_new("(tsssb)", target.targetIdentifier(), "Automation", target.name().utf8().data(), "null", target.isPaired());
+    return g_variant_new("(tsssb)", static_cast<guint64>(target.targetIdentifier()),
+        "Automation", target.name().utf8().data(), "null", target.isPaired());
 }
 
 void RemoteInspector::pushListingsNow()
@@ -274,7 +276,7 @@ void RemoteInspector::sendMessageToRemote(unsigned targetIdentifier, const Strin
 
     g_dbus_connection_call(m_dbusConnection.get(), nullptr,
         INSPECTOR_DBUS_OBJECT_PATH, INSPECTOR_DBUS_INTERFACE, "SendMessageToFrontend",
-        g_variant_new("(ts)", targetIdentifier, message.utf8().data()),
+        g_variant_new("(ts)", static_cast<guint64>(targetIdentifier), message.utf8().data()),
         nullptr, G_DBUS_CALL_FLAGS_NO_AUTO_START,
         -1, m_cancellable.get(), dbusConnectionCallAsyncReadyCallback, nullptr);
 }
index 011a84b..9eb1456 100644 (file)
@@ -1,3 +1,17 @@
+2017-08-17  Jacobo Aragunde Pérez  <jaragunde@igalia.com>
+
+        [WPE][GTK] Ensure proper casting of data in gvariants
+        https://bugs.webkit.org/show_bug.cgi?id=175667
+
+        Reviewed by Michael Catanzaro.
+
+        g_variant_builder_add requires data to have the correct width for their types, using
+        casting if necessary. Corrected a call where a single precision float was being put
+        into a double precision parameter without a cast.
+
+        * UIProcess/API/glib/WebKitWebViewSessionState.cpp:
+        (encodeFrameState):
+
 2017-08-17  Don Olmstead  <don.olmstead@sony.com>
 
         [PAL] Move SessionID into PAL
index 325d014..4bea267 100644 (file)
@@ -171,7 +171,7 @@ static inline void encodeFrameState(GVariantBuilder* sessionBuilder, const Frame
     g_variant_builder_add(sessionBuilder, "x", frameState.documentSequenceNumber);
     g_variant_builder_add(sessionBuilder, "x", frameState.itemSequenceNumber);
     g_variant_builder_add(sessionBuilder, "(ii)", frameState.scrollPosition.x(), frameState.scrollPosition.y());
-    g_variant_builder_add(sessionBuilder, "d", frameState.pageScaleFactor);
+    g_variant_builder_add(sessionBuilder, "d", static_cast<gdouble>(frameState.pageScaleFactor));
     if (!frameState.httpBody)
         g_variant_builder_add(sessionBuilder, HTTP_BODY_TYPE_STRING_V1, FALSE);
     else {