[systemd-devel] [PATCH] dbus-common: fix segfault when a DBus message has no interface

Michal Schmidt mschmidt at redhat.com
Wed May 25 07:17:17 PDT 2011


dbus_message_get_interface() may return NULL.

https://bugzilla.redhat.com/show_bug.cgi?id=707483
---
 src/dbus-common.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/dbus-common.c b/src/dbus-common.c
index 9bf0dab..5db077b 100644
--- a/src/dbus-common.c
+++ b/src/dbus-common.c
@@ -418,9 +418,13 @@ DBusHandlerResult bus_default_message_handler(
                         return bus_send_error_reply(c, message, &error, -EINVAL);
                 }
 
-        } else if (!nulstr_contains(interfaces, dbus_message_get_interface(message))) {
-                dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
-                return bus_send_error_reply(c, message, &error, -EINVAL);
+        } else {
+                const char *interface = dbus_message_get_interface(message);
+
+                if (!interface || !nulstr_contains(interfaces, interface)) {
+                        dbus_set_error_const(&error, DBUS_ERROR_UNKNOWN_INTERFACE, "Unknown interface");
+                        return bus_send_error_reply(c, message, &error, -EINVAL);
+                }
         }
 
         if (reply) {
-- 
1.7.5.2



More information about the systemd-devel mailing list