summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Rauwolf <rauwolf@itestra.de>2013-03-13 10:48:24 +0100
committerPhilip Rauwolf <rauwolf@itestra.de>2013-03-13 10:48:24 +0100
commit98601b459983368839798d83aa43542bb66a1f94 (patch)
tree8ceb3a6eff2a1eb3b944632aaed195ba64a65c50
parentb5756991e81d2877f9a0eb1f03313546744a370a (diff)
downloadgenivi-common-api-dbus-runtime-98601b459983368839798d83aa43542bb66a1f94.tar.gz
Fixed bug that allowed the destructor of a proxy to access invalid2.0.1
memory, thus causing segfaults
-rw-r--r--src/CommonAPI/DBus/DBusDaemonProxy.cpp30
-rw-r--r--src/CommonAPI/DBus/DBusDaemonProxy.h14
-rw-r--r--src/CommonAPI/DBus/DBusProxy.cpp40
-rw-r--r--src/CommonAPI/DBus/DBusProxy.h16
-rw-r--r--src/CommonAPI/DBus/DBusProxyBase.cpp46
-rw-r--r--src/CommonAPI/DBus/DBusProxyBase.h64
6 files changed, 115 insertions, 95 deletions
diff --git a/src/CommonAPI/DBus/DBusDaemonProxy.cpp b/src/CommonAPI/DBus/DBusDaemonProxy.cpp
index f18d2ac..80bd233 100644
--- a/src/CommonAPI/DBus/DBusDaemonProxy.cpp
+++ b/src/CommonAPI/DBus/DBusDaemonProxy.cpp
@@ -32,12 +32,40 @@ std::future<CallStatus> StaticInterfaceVersionAttribute::getValueAsync(Attribute
StaticInterfaceVersionAttribute DBusDaemonProxy::interfaceVersionAttribute_(1, 0);
+const std::string DBusDaemonProxy::dbusBusName_ = "org.freedesktop.DBus";
+const std::string DBusDaemonProxy::dbusObjectPath_ = "/org/freedesktop/DBus";
+const std::string DBusDaemonProxy::dbusInterfaceName_ = getInterfaceId();
+const std::string DBusDaemonProxy::commonApiParticipantId_ = "org.freedesktop.DBus-/org/freedesktop/DBus";
+
DBusDaemonProxy::DBusDaemonProxy(const std::shared_ptr<DBusProxyConnection>& dbusConnection):
- DBusProxyBase(getInterfaceId(), "org.freedesktop.DBus", "/org/freedesktop/DBus", dbusConnection),
+ DBusProxyBase(dbusConnection),
nameOwnerChangedEvent_(*this, "NameOwnerChanged", "sss") {
}
+std::string DBusDaemonProxy::getAddress() const {
+ return getDomain() + ":" + getServiceId() + ":" + getInstanceId();
+}
+const std::string& DBusDaemonProxy::getDomain() const {
+ return commonApiDomain_;
+}
+const std::string& DBusDaemonProxy::getServiceId() const {
+ return dbusInterfaceName_;
+}
+const std::string& DBusDaemonProxy::getInstanceId() const {
+ return commonApiParticipantId_;
+}
+
+const std::string& DBusDaemonProxy::getDBusBusName() const {
+ return dbusBusName_;
+}
+const std::string& DBusDaemonProxy::getDBusObjectPath() const {
+ return dbusObjectPath_;
+}
+const std::string& DBusDaemonProxy::getInterfaceName() const {
+ return dbusInterfaceName_;
+}
+
bool DBusDaemonProxy::isAvailable() const {
return getDBusConnection()->isConnected();
}
diff --git a/src/CommonAPI/DBus/DBusDaemonProxy.h b/src/CommonAPI/DBus/DBusDaemonProxy.h
index aeb2feb..9fa2cd2 100644
--- a/src/CommonAPI/DBus/DBusDaemonProxy.h
+++ b/src/CommonAPI/DBus/DBusDaemonProxy.h
@@ -61,9 +61,23 @@ class DBusDaemonProxy: public DBusProxyBase {
std::future<CallStatus> getManagedObjectsAsync(const std::string& forDBusServiceName, GetManagedObjectsAsyncCallback) const;
+ virtual std::string getAddress() const;
+ virtual const std::string& getDomain() const;
+ virtual const std::string& getServiceId() const;
+ virtual const std::string& getInstanceId() const;
+
+ virtual const std::string& getDBusBusName() const;
+ virtual const std::string& getDBusObjectPath() const;
+ virtual const std::string& getInterfaceName() const;
+
private:
DBusEvent<NameOwnerChangedEvent> nameOwnerChangedEvent_;
static StaticInterfaceVersionAttribute interfaceVersionAttribute_;
+
+ static const std::string dbusBusName_;
+ static const std::string dbusObjectPath_;
+ static const std::string commonApiParticipantId_;
+ static const std::string dbusInterfaceName_;
};
const char* DBusDaemonProxy::getInterfaceId() {
diff --git a/src/CommonAPI/DBus/DBusProxy.cpp b/src/CommonAPI/DBus/DBusProxy.cpp
index a556ba8..9946859 100644
--- a/src/CommonAPI/DBus/DBusProxy.cpp
+++ b/src/CommonAPI/DBus/DBusProxy.cpp
@@ -33,12 +33,12 @@ DBusProxy::DBusProxy(const std::string& commonApiAddress,
const std::string& dbusBusName,
const std::string& dbusObjectPath,
const std::shared_ptr<DBusProxyConnection>& dbusConnection):
- DBusProxyBase(split(commonApiAddress, ':')[1],
- split(commonApiAddress, ':')[2],
- dbusInterfaceName,
- dbusBusName,
- dbusObjectPath,
- dbusConnection),
+ DBusProxyBase(dbusConnection),
+ commonApiServiceId_(split(commonApiAddress, ':')[1]),
+ commonApiParticipantId_(split(commonApiAddress, ':')[2]),
+ dbusBusName_(dbusBusName),
+ dbusObjectPath_(dbusObjectPath),
+ dbusInterfaceName_(dbusInterfaceName),
dbusProxyStatusEvent_(this),
availabilityStatus_(AvailabilityStatus::UNKNOWN),
interfaceVersionAttribute_(*this, "getInterfaceVersion"),
@@ -88,5 +88,33 @@ void DBusProxy::onDBusServiceInstanceStatus(const AvailabilityStatus& availabili
dbusProxyStatusEvent_.notifyListeners(availabilityStatus);
}
+const std::string& DBusProxy::getDBusBusName() const {
+ return dbusBusName_;
+}
+
+const std::string& DBusProxy::getDBusObjectPath() const {
+ return dbusObjectPath_;
+}
+
+const std::string& DBusProxy::getInterfaceName() const {
+ return dbusInterfaceName_;
+}
+
+const std::string& DBusProxy::getDomain() const {
+ return commonApiDomain_;
+}
+
+const std::string& DBusProxy::getServiceId() const {
+ return commonApiServiceId_;
+}
+
+const std::string& DBusProxy::getInstanceId() const {
+ return commonApiParticipantId_;
+}
+
+std::string DBusProxy::getAddress() const {
+ return commonApiDomain_ + ":" + commonApiServiceId_ + ":" + commonApiParticipantId_;
+}
+
} // namespace DBus
} // namespace CommonAPI
diff --git a/src/CommonAPI/DBus/DBusProxy.h b/src/CommonAPI/DBus/DBusProxy.h
index 6021a01..e838f6b 100644
--- a/src/CommonAPI/DBus/DBusProxy.h
+++ b/src/CommonAPI/DBus/DBusProxy.h
@@ -48,6 +48,15 @@ class DBusProxy: public DBusProxyBase {
virtual bool isAvailableBlocking() const;
+ virtual std::string getAddress() const;
+ virtual const std::string& getDomain() const;
+ virtual const std::string& getServiceId() const;
+ virtual const std::string& getInstanceId() const;
+
+ virtual const std::string& getDBusBusName() const;
+ virtual const std::string& getDBusObjectPath() const;
+ virtual const std::string& getInterfaceName() const;
+
private:
DBusProxy(const DBusProxy&) = delete;
@@ -61,6 +70,13 @@ class DBusProxy: public DBusProxyBase {
DBusReadonlyAttribute<InterfaceVersionAttribute> interfaceVersionAttribute_;
std::shared_ptr<DBusServiceRegistry> dbusServiceRegistry_;
+
+ const std::string commonApiServiceId_;
+ const std::string commonApiParticipantId_;
+
+ const std::string dbusBusName_;
+ const std::string dbusObjectPath_;
+ const std::string dbusInterfaceName_;
};
diff --git a/src/CommonAPI/DBus/DBusProxyBase.cpp b/src/CommonAPI/DBus/DBusProxyBase.cpp
index 8cb2400..633fab4 100644
--- a/src/CommonAPI/DBus/DBusProxyBase.cpp
+++ b/src/CommonAPI/DBus/DBusProxyBase.cpp
@@ -12,54 +12,16 @@ namespace DBus {
const std::string DBusProxyBase::commonApiDomain_ = "local";
-DBusProxyBase::DBusProxyBase(const std::string& commonApiServiceId,
- const std::string& commonApiParticipantId,
- const std::string& dbusInterfaceName,
- const std::string& dbusBusName,
- const std::string& dbusObjectPath,
- const std::shared_ptr<DBusProxyConnection>& dbusConnection) :
- commonApiServiceId_(commonApiServiceId),
- commonApiParticipantId_(commonApiParticipantId),
- dbusBusName_(dbusBusName),
- dbusObjectPath_(dbusObjectPath),
- dbusInterfaceName_(dbusInterfaceName),
+DBusProxyBase::DBusProxyBase(const std::shared_ptr<DBusProxyConnection>& dbusConnection) :
dbusConnection_(dbusConnection) {
}
-DBusProxyBase::DBusProxyBase(const std::string& dbusInterfaceName,
- const std::string& dbusBusName,
- const std::string& dbusObjectPath,
- const std::shared_ptr<DBusProxyConnection>& dbusConnection) :
- commonApiServiceId_(dbusInterfaceName),
- commonApiParticipantId_(dbusBusName + "-" + dbusObjectPath),
- dbusBusName_(dbusBusName),
- dbusObjectPath_(dbusObjectPath),
- dbusInterfaceName_(dbusInterfaceName),
- dbusConnection_(dbusConnection) {
-}
-
-std::string DBusProxyBase::getAddress() const {
- return commonApiDomain_ + ":" + commonApiServiceId_ + ":" + commonApiParticipantId_;
-}
-
-const std::string& DBusProxyBase::getDomain() const {
- return commonApiDomain_;
-}
-
-const std::string& DBusProxyBase::getServiceId() const {
- return commonApiServiceId_;
-}
-
-const std::string& DBusProxyBase::getInstanceId() const {
- return commonApiParticipantId_;
-}
-
DBusMessage DBusProxyBase::createMethodCall(const char* methodName,
const char* methodSignature) const {
return DBusMessage::createMethodCall(
- dbusBusName_.c_str(),
- dbusObjectPath_.c_str(),
- dbusInterfaceName_.c_str(),
+ getDBusBusName().c_str(),
+ getDBusObjectPath().c_str(),
+ getInterfaceName().c_str(),
methodName,
methodSignature);
}
diff --git a/src/CommonAPI/DBus/DBusProxyBase.h b/src/CommonAPI/DBus/DBusProxyBase.h
index 10b5bae..686c878 100644
--- a/src/CommonAPI/DBus/DBusProxyBase.h
+++ b/src/CommonAPI/DBus/DBusProxyBase.h
@@ -21,26 +21,16 @@ namespace DBus {
class DBusProxyBase: public virtual CommonAPI::Proxy {
public:
- DBusProxyBase(const std::string& commonApiServiceId,
- const std::string& commonApiParticipantId,
- const std::string& dbusInterfaceName,
- const std::string& dbusBusName,
- const std::string& dbusObjectPath,
- const std::shared_ptr<DBusProxyConnection>& dbusProxyConnection);
-
- DBusProxyBase(const std::string& dbusInterfaceName,
- const std::string& dbusBusName,
- const std::string& dbusObjectPath,
- const std::shared_ptr<DBusProxyConnection>& dbusProxyConnection);
-
- virtual std::string getAddress() const;
- virtual const std::string& getDomain() const;
- virtual const std::string& getServiceId() const;
- virtual const std::string& getInstanceId() const;
-
- inline const std::string& getDBusBusName() const;
- inline const std::string& getDBusObjectPath() const;
- inline const std::string& getInterfaceName() const;
+ DBusProxyBase(const std::shared_ptr<DBusProxyConnection>& dbusProxyConnection);
+
+ virtual std::string getAddress() const = 0;
+ virtual const std::string& getDomain() const = 0;
+ virtual const std::string& getServiceId() const = 0;
+ virtual const std::string& getInstanceId() const = 0;
+
+ virtual const std::string& getDBusBusName() const = 0;
+ virtual const std::string& getDBusObjectPath() const = 0;
+ virtual const std::string& getInterfaceName() const = 0;
inline const std::shared_ptr<DBusProxyConnection>& getDBusConnection() const;
DBusMessage createMethodCall(const char* methodName,
@@ -53,33 +43,15 @@ class DBusProxyBase: public virtual CommonAPI::Proxy {
inline void removeSignalMemberHandler(const DBusProxyConnection::DBusSignalHandlerToken& dbusSignalHandlerToken);
+ protected:
+ static const std::string commonApiDomain_;
+
private:
DBusProxyBase(const DBusProxyBase&) = delete;
- const std::string commonApiServiceId_;
- const std::string commonApiParticipantId_;
-
- const std::string dbusBusName_;
- const std::string dbusObjectPath_;
- const std::string dbusInterfaceName_;
-
std::shared_ptr<DBusProxyConnection> dbusConnection_;
-
- static const std::string commonApiDomain_;
};
-const std::string& DBusProxyBase::getDBusBusName() const {
- return dbusBusName_;
-}
-
-const std::string& DBusProxyBase::getDBusObjectPath() const {
- return dbusObjectPath_;
-}
-
-const std::string& DBusProxyBase::getInterfaceName() const {
- return dbusInterfaceName_;
-}
-
const std::shared_ptr<DBusProxyConnection>& DBusProxyBase::getDBusConnection() const {
return dbusConnection_;
}
@@ -89,11 +61,11 @@ DBusProxyConnection::DBusSignalHandlerToken DBusProxyBase::addSignalMemberHandle
const std::string& signalSignature,
DBusProxyConnection::DBusSignalHandler* dbusSignalHandler) {
return dbusConnection_->addSignalMemberHandler(
- dbusObjectPath_,
- getInterfaceName(),
- signalName,
- signalSignature,
- dbusSignalHandler);
+ getDBusObjectPath(),
+ getInterfaceName(),
+ signalName,
+ signalSignature,
+ dbusSignalHandler);
}
void DBusProxyBase::removeSignalMemberHandler(const DBusProxyConnection::DBusSignalHandlerToken& dbusSignalHandlerToken) {