]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
bus_registry_new: Assert in case of not valid context parameter to avoid potiental...
authorRalf Habacker <ralf.habacker@freenet.de>
Tue, 21 Apr 2015 11:16:53 +0000 (13:16 +0200)
committerRalf Habacker <ralf.habacker@freenet.de>
Mon, 13 Jul 2015 12:33:32 +0000 (14:33 +0200)
Because the context parameter is dereferenced several times in related code without a null check,
we need to make sure to have a valid context.

Reported by Coverity: CID 54764: Dereference after null check (FORWARD_NULL)

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90021
Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
bus/services.c

index 8e625867f44a932753d9c2cad18c45e21ebe1c96..6a4c8848d9d3722e3c7c0e0f102cbc8654581330 100644 (file)
@@ -76,6 +76,7 @@ bus_registry_new (BusContext *context)
 {
   BusRegistry *registry;
 
+  _dbus_assert (context);
   registry = dbus_new0 (BusRegistry, 1);
   if (registry == NULL)
     return NULL;
@@ -461,8 +462,7 @@ bus_registry_acquire_service (BusRegistry      *registry,
     }
 
   if (!bus_apparmor_allows_acquire_service (connection,
-                                            (registry->context ?
-                                             bus_context_get_type (registry->context) : NULL),
+                                            bus_context_get_type (registry->context),
                                             _dbus_string_get_const_data (service_name), error))
     goto out;