dbus-c++ does not correctly handle messages with NULL interface

Schmottlach, Glenn glenn.schmottlach at harman.com
Wed May 27 06:24:08 PDT 2009


That's not the only place where the C++ binding could conceivably run
into trouble. In message.cpp both the CallMessage and SignalMessage have
interface() and member() methods which could conceivably return NULL.
There is plenty of code in object.cpp that references these members and
assumes the const char* returned is non-NULL.

Do I have a suggestion to fix this . . . no. At a minimum, however, the
interface() and member() methods in message.cpp could return an empty
string ("") in cases where the underlying D-Bus calls
(dbus_message_get_interface() and dbus_message_get_member()) might
return NULL. Not optimal, but at least the binding wouldn't crash.

The larger question (and I'm not D-Bus protocol expert) is to understand
under what circumstances would you expect dbus_message_get_interface()
and dbus_message_get_member() to return NULL. Is this a typical scenario
often seen on the D-Bus or a more esoteric situation?


-----Original Message-----
From: dbus-bounces at lists.freedesktop.org
[mailto:dbus-bounces at lists.freedesktop.org] On Behalf Of Eric Jonas
Sent: Wednesday, May 20, 2009 11:20 AM
To: dbus at lists.freedesktop.org
Subject: dbus-c++ does not correctly handle messages with NULL interface

I've been using dbus-c++ for a while now, and it appears that it does
not correctly handle the case where dbus_message_get_interface returns
NULL. Looking at the invocation of find_interface within object.cpp
around line 200 or so, we see that it's passing char *interface to the
find_interface method which expects a std::string. c++ attempts the
automatic construction, which fails, and the app crashes. 

I've poked around a little bit, and while it would be easy to have
dbus-c++ just fail to respond to messages with null interfaces, that
seems a bit suboptimal, as lots of code (including the python-dbus
example) does not explicitly have you accessing the proxy object through
the interface. But grafting on method-lookup code seems like a bit of
work too. Any suggestions/thoughts? 

			...Eric Jonas

_______________________________________________
dbus mailing list
dbus at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dbus



More information about the dbus mailing list