From 9c4741153c47940fb5f509a86760c899eb65ecb8 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Tue, 13 Feb 2018 13:59:39 +0100 Subject: [PATCH] Bug 1418770 - Truncate DBus names used for remote service to DBUS_MAXIMUM_NAME_LENGTH, r=jhorak MozReview-Commit-ID: 3Hrt3Ef87WD --HG-- extra : rebase_source : 9ece42adec435b244f5875f7e3449f6268c0beea --- toolkit/components/remote/nsDBusRemoteService.cpp | 3 +++ widget/xremoteclient/DBusRemoteClient.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/toolkit/components/remote/nsDBusRemoteService.cpp b/toolkit/components/remote/nsDBusRemoteService.cpp index 7cd9b53ed446..21336fb1b60e 100644 --- a/toolkit/components/remote/nsDBusRemoteService.cpp +++ b/toolkit/components/remote/nsDBusRemoteService.cpp @@ -186,6 +186,9 @@ nsDBusRemoteService::Startup(const char* aAppName, const char* aProfileName) 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(), diff --git a/widget/xremoteclient/DBusRemoteClient.cpp b/widget/xremoteclient/DBusRemoteClient.cpp index 2ca1cafa9a2a..c85c5b868b6f 100644 --- a/widget/xremoteclient/DBusRemoteClient.cpp +++ b/widget/xremoteclient/DBusRemoteClient.cpp @@ -133,6 +133,9 @@ DBusRemoteClient::GetRemoteDestinationName(const char *aProgram, aDestinationName = nsPrintfCString("org.mozilla.%s.%s", aProgram, profileName.get()); + if (aDestinationName.Length() > DBUS_MAXIMUM_NAME_LENGTH) + aDestinationName.Truncate(DBUS_MAXIMUM_NAME_LENGTH); + return true; } }