OSDN Git Service

network: Fix missing NULL check for given UUID
authorMikel Astiz <mikel.astiz@bmw-carit.de>
Mon, 27 May 2013 12:04:05 +0000 (14:04 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 24 Jun 2013 08:16:43 +0000 (11:16 +0300)
The code dereferences a NULL pointer if find_connection() doesn't find
an existing connection, which will be the case if the input UUID is
invalid or not supported.

profiles/network/connection.c

index 84f3dd6..bac3b69 100644 (file)
@@ -426,7 +426,10 @@ static DBusMessage *local_connect(DBusConnection *conn,
        id = bnep_service_id(svc);
 
        nc = find_connection(peer->connections, id);
-       if (nc && nc->connect)
+       if (nc == NULL)
+               return btd_error_invalid_args(msg);
+
+       if (nc->connect != NULL)
                return btd_error_busy(msg);
 
        err = connection_connect(nc->service);