]> err.no Git - systemd/commitdiff
dbus-common: fix segfault when a DBus message has no interface
authorMichal Schmidt <mschmidt@redhat.com>
Wed, 25 May 2011 14:17:17 +0000 (16:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 25 May 2011 16:07:31 +0000 (18:07 +0200)
dbus_message_get_interface() may return NULL.

https://bugzilla.redhat.com/show_bug.cgi?id=707483

src/dbus-common.c

index 9bf0dabe4cf1da450dc84d3a58f63330059064ef..5db077b74fb8115157cd8932ea1a8b98ae70c188 100644 (file)
@@ -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) {