Skip to contentSkip to conversation

core/profile: Fix possible crash when registering profiles

PATCH Applied Luiz Augusto von Dentz 1 participant 2 messages Nov 5, 2015 – Nov 8, 2015 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH 1/1 core/profile: Fix possible crash when registering profiles

From: Luiz Augusto von Dentz <[email protected]>

Profiles under ext_profiles are local and should no be mixed with other external profiles since its type is different which can may cause invalid memory when accessing member of ext_profile struct.

---
 src/profile.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
src/profile.c +2 -12
index 49445d7..5a4f09c 100644
@@ -719,19 +719,13 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
 
 int btd_profile_register(struct btd_profile *profile)
 {
-	if (profile->external)
-		ext_profiles = g_slist_append(ext_profiles, profile);
-	else
-		profiles = g_slist_append(profiles, profile);
+	profiles = g_slist_append(profiles, profile);
 	return 0;
 }
 
 void btd_profile_unregister(struct btd_profile *profile)
 {
-	if (profile->external)
-		ext_profiles = g_slist_remove(ext_profiles, profile);
-	else
-		profiles = g_slist_remove(profiles, profile);
+	profiles = g_slist_remove(profiles, profile);
 }
 
 static struct ext_profile *find_ext_profile(const char *owner,
@@ -742,10 +736,6 @@ static struct ext_profile *find_ext_profile(const char *owner,
 	for (l = ext_profiles; l != NULL; l = g_slist_next(l)) {
 		struct ext_profile *ext = l->data;
 
-		/*
-		 * Owner and path can be NULL if profile was registered by a
-		 * plugin using external flag.
-		 */
 		if (g_strcmp0(ext->owner, owner))
 			continue;
 
Signature · 1 line
2.4.3
author maintainer Applied
#1 lore raw

Hi,

Quoted 47 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

Profiles under ext_profiles are local and should no be mixed with other external profiles since its type is different which can may cause invalid memory when accessing member of ext_profile struct.

---
 src/profile.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
src/profile.c +2 -13
index 49445d7..5a4f09c 100644
@@ -719,19 +719,13 @@ void btd_profile_foreach(void (*func)(struct btd_profile *p, void *data),
 
 int btd_profile_register(struct btd_profile *profile)
 {
-       if (profile->external)
-               ext_profiles = g_slist_append(ext_profiles, profile);
-       else
-               profiles = g_slist_append(profiles, profile);
+       profiles = g_slist_append(profiles, profile);
        return 0;
 }
 
 void btd_profile_unregister(struct btd_profile *profile)
 {
-       if (profile->external)
-               ext_profiles = g_slist_remove(ext_profiles, profile);
-       else
-               profiles = g_slist_remove(profiles, profile);
+       profiles = g_slist_remove(profiles, profile);
 }
 
 static struct ext_profile *find_ext_profile(const char *owner,
@@ -742,10 +736,6 @@ static struct ext_profile *find_ext_profile(const char *owner,
        for (l = ext_profiles; l != NULL; l = g_slist_next(l)) {
                struct ext_profile *ext = l->data;
 
-               /*
-                * Owner and path can be NULL if profile was registered by a
-                * plugin using external flag.
-                */
                if (g_strcmp0(ext->owner, owner))
                        continue;
 
--
Quoted 1 line

2.4.3

Applied.

Signature · 1 line
Luiz Augusto von Dentz