From 6b491fa02a4fbc37a614cab0e451fd0984fe2d64 Mon Sep 17 00:00:00 2001 From: ozoder Date: Wed, 4 Jul 2018 09:24:34 +0200 Subject: [PATCH] Bug 1472611 - Don't link DBus 1.5.12 symbol dbus_validate_bus_name(), r=stransky MozReview-Commit-ID: 6scVh8DOex2 --HG-- extra : rebase_source : d66577a13d06b1a1bdcd1ec0e25fd1dc75d84a1e --- toolkit/components/remote/nsDBusRemoteService.cpp | 13 +++++++++++-- widget/xremoteclient/DBusRemoteClient.cpp | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/toolkit/components/remote/nsDBusRemoteService.cpp b/toolkit/components/remote/nsDBusRemoteService.cpp index c79cde8a9be6..e89092da2341 100644 --- a/toolkit/components/remote/nsDBusRemoteService.cpp +++ b/toolkit/components/remote/nsDBusRemoteService.cpp @@ -27,6 +27,8 @@ #include #include +#include + NS_IMPL_ISUPPORTS(nsDBusRemoteService, nsIRemoteService) @@ -189,10 +191,17 @@ nsDBusRemoteService::Startup(const char* aAppName, const char* aProfileName) if (busName.Length() > DBUS_MAXIMUM_NAME_LENGTH) busName.Truncate(DBUS_MAXIMUM_NAME_LENGTH); + static auto sDBusValidateBusName = + (bool (*)(const char *, DBusError *)) + dlsym(RTLD_DEFAULT, "dbus_validate_bus_name"); + if (!sDBusValidateBusName) { + return NS_ERROR_FAILURE; + } + // We don't have a valid busName yet - try to create a default one. - if (!dbus_validate_bus_name(busName.get(), nullptr)) { + if (!sDBusValidateBusName(busName.get(), nullptr)) { busName = nsPrintfCString("org.mozilla.%s.%s", mAppName.get(), "default"); - if (!dbus_validate_bus_name(busName.get(), nullptr)) { + if (!sDBusValidateBusName(busName.get(), nullptr)) { // We failed completelly to get a valid bus name - just quit // to prevent crash at dbus_bus_request_name(). return NS_ERROR_FAILURE; diff --git a/widget/xremoteclient/DBusRemoteClient.cpp b/widget/xremoteclient/DBusRemoteClient.cpp index 931e03d6aa05..1919ad027a14 100644 --- a/widget/xremoteclient/DBusRemoteClient.cpp +++ b/widget/xremoteclient/DBusRemoteClient.cpp @@ -12,6 +12,8 @@ #include "mozilla/Base64.h" #include "nsPrintfCString.h" +#include + using mozilla::LogLevel; static mozilla::LazyLogModule sRemoteLm("DBusRemoteClient"); @@ -136,11 +138,18 @@ DBusRemoteClient::GetRemoteDestinationName(const char *aProgram, if (aDestinationName.Length() > DBUS_MAXIMUM_NAME_LENGTH) aDestinationName.Truncate(DBUS_MAXIMUM_NAME_LENGTH); - if (!dbus_validate_bus_name(aDestinationName.get(), nullptr)) { + static auto sDBusValidateBusName = + (bool (*)(const char *, DBusError *)) + dlsym(RTLD_DEFAULT, "dbus_validate_bus_name"); + if (!sDBusValidateBusName) { + return false + } + + if (!sDBusValidateBusName(aDestinationName.get(), nullptr)) { // We don't have a valid busName yet - try to create a default one. aDestinationName = nsPrintfCString("org.mozilla.%s.%s", aProgram, "default"); - if (!dbus_validate_bus_name(aDestinationName.get(), nullptr)) { + if (!sDBusValidateBusName(aDestinationName.get(), nullptr)) { // We failed completelly to get a valid bus name - just quit // to prevent crash at dbus_bus_request_name(). return false;