diff --git a/src/profile.c b/src/profile.c
index 5e460b6..60d17b6 100644
--- a/src/profile.c
+++ b/src/profile.c
}
}
+static struct btd_profile *btd_profile_find_uuid(const char *uuid)
+{
+ GSList *l, *next;
+
+ for (l = profiles; l != NULL; l = next) {
+ struct btd_profile *p = l->data;
+
+ if (!g_strcmp0(p->local_uuid, uuid))
+ return p;
+ next = g_slist_next(l);
+ }
+
+ for (l = ext_profiles; l != NULL; l = next) {
+ struct ext_profile *ext = l->data;
+ struct btd_profile *p = &ext->p;
+
+ if (!g_strcmp0(p->local_uuid, uuid))
+ return p;
+ next = g_slist_next(l);
+ }
+
+ return NULL;
+}
+
int btd_profile_register(struct btd_profile *profile)
{
profiles = g_slist_append(profiles, profile);
dbus_message_iter_get_basic(&args, &uuid);
dbus_message_iter_next(&args);
+ if (btd_profile_find_uuid(uuid)) {
+ warn("%s tried to register %s which is already registered",
+ sender, uuid);
+ return btd_error_not_permitted(msg, "UUID already registered");
+ }
+
if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY)
return btd_error_invalid_args(msg);