Bug 1418770 - Truncate DBus names used for remote service to DBUS_MAXIMUM_NAME_LENGTH, r=jhorak a=RyanVM
authorMartin Stransky <stransky@redhat.com>
Tue, 13 Feb 2018 13:59:39 +0100
changeset 454995 28b5b075c5e6dc6284113646b22a523f5abb02c3
parent 454994 df143d7bcd1930faf76dc99159781d1d378e4e73
child 454996 abc5f0d35082241616975246fd770c77359a0d5e
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak, RyanVM
bugs1418770
milestone59.0
Bug 1418770 - Truncate DBus names used for remote service to DBUS_MAXIMUM_NAME_LENGTH, r=jhorak a=RyanVM MozReview-Commit-ID: 3Hrt3Ef87WD
toolkit/components/remote/nsDBusRemoteService.cpp
widget/xremoteclient/DBusRemoteClient.cpp
--- a/toolkit/components/remote/nsDBusRemoteService.cpp
+++ b/toolkit/components/remote/nsDBusRemoteService.cpp
@@ -177,16 +177,19 @@ nsDBusRemoteService::Startup(const char*
   nsAutoCString profileName;
   nsresult rv = mozilla::Base64Encode(nsAutoCString(aProfileName), profileName);
   NS_ENSURE_SUCCESS(rv, rv);
   profileName.ReplaceChar("+/=", '_');
 
   nsAutoCString busName;
   busName = nsPrintfCString("org.mozilla.%s.%s", mAppName.get(),
                                                  profileName.get());
+  if (busName.Length() > DBUS_MAXIMUM_NAME_LENGTH)
+    busName.Truncate(DBUS_MAXIMUM_NAME_LENGTH);
+
   DBusError err;
   dbus_error_init(&err);
   dbus_bus_request_name(mConnection, busName.get(),
                        DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
   // The interface is already owned - there is another application/profile
   // instance already running.
   if (dbus_error_is_set(&err)) {
     dbus_error_free(&err);
--- a/widget/xremoteclient/DBusRemoteClient.cpp
+++ b/widget/xremoteclient/DBusRemoteClient.cpp
@@ -90,16 +90,18 @@ DBusRemoteClient::DoSendDBusCommandLine(
   // characters so adjust the profile string properly.
   nsAutoCString profileName;
   nsresult rv = mozilla::Base64Encode(nsAutoCString(aProfile), profileName);
   NS_ENSURE_SUCCESS(rv, rv);
   profileName.ReplaceChar("+/=", '_');
 
   nsAutoCString destinationName;
   destinationName = nsPrintfCString("org.mozilla.%s.%s", aProgram, profileName.get());
+  if (destinationName.Length() > DBUS_MAXIMUM_NAME_LENGTH)
+    destinationName.Truncate(DBUS_MAXIMUM_NAME_LENGTH);
 
   nsAutoCString pathName;
   pathName = nsPrintfCString("/org/mozilla/%s/Remote", aProgram);
 
   nsAutoCString remoteInterfaceName;
   remoteInterfaceName = nsPrintfCString("org.mozilla.%s", aProgram);
 
   RefPtr<DBusMessage> msg = already_AddRefed<DBusMessage>(