From: Simon Mikuda <simon.mikuda@streamunlimited.com>
To: linux-bluetooth@vger.kernel.org
Cc: Simon Mikuda <simon.mikuda@streamunlimited.com>
Subject: [PATCH BlueZ 6/8] player: Fix crash on Search in a folder with a space in its name
Date: Sun, 22 Nov 2026 11:57:29 +0100 [thread overview]
Message-ID: <20261122105731.799090-7-simon.mikuda@streamunlimited.com> (raw)
In-Reply-To: <20261122105731.799090-1-simon.mikuda@streamunlimited.com>
The search folder object path is made from the name of the folder
searched, e.g. /Filesystem/My Music/search. A name with characters an
object path cannot have, such as a space, fails to register, and
media_player_search_complete() dereferences the NULL item.
To reproduce, browse a target with a folder named "My Music", change to
it and call Search:
media_player_create_subfolder() /Filesystem/My Music/search
media_folder_create_item() D-Bus failed to register
org.bluez.MediaItem1 on
/org/bluez/hci0/dev_00_AA_01_01_00_42/avrcp/player0/Filesystem/My
Music/search path
Program terminated with signal SIGSEGV, Segmentation fault.
#0 dbus_message_iter_append_basic () from libdbus-1.so.3
#1 dbus_message_append_args_valist () from libdbus-1.so.3
#2 g_dbus_create_reply_valist (...) at gdbus/object.c:1572
#3 g_dbus_create_reply (...) at gdbus/object.c:1587
#4 media_player_search_complete (mp=..., ret=2) at
profiles/audio/player.c:741
#5 avrcp_search_rsp (...) at profiles/audio/avrcp.c:4460
#6 browsing_response (...) at profiles/audio/avctp.c:964
Replace those characters with '_' in the object path of a folder named
by its path, as the search folder and the folders of the browsed player
are, and fail the search if the folder still cannot be created.
Fixes: 0a232a434d4b ("audio/player: Add implementation of MediaFolder.Search")
Assisted-by: Claude:claude-opus-5-5
---
profiles/audio/player.c | 27 ++++++++++++++++++++++++---
1 file changed, 24 insertions(+), 3 deletions(-)
diff --git a/profiles/audio/player.c b/profiles/audio/player.c
index 4c94dcab4..574a026ac 100644
--- a/profiles/audio/player.c
+++ b/profiles/audio/player.c
@@ -730,8 +730,17 @@ void media_player_search_complete(struct media_player *mp, int ret)
}
if (search == NULL) {
+ struct media_item *item;
+
+ item = media_player_create_subfolder(mp, "search", 0);
+ if (item == NULL) {
+ reply = btd_error_failed(mp->msg,
+ "Unable to create search folder");
+ goto done;
+ }
+
search = g_new0(struct media_folder, 1);
- search->item = media_player_create_subfolder(mp, "search", 0);
+ search->item = item;
mp->search = search;
mp->folders = g_slist_prepend(mp->folders, search);
}
@@ -1890,11 +1899,23 @@ static struct media_item *media_folder_create_item(struct media_player *mp,
item->player = mp;
item->uid = uid;
- if (!uid && name[0] == '/')
+ if (!uid && name[0] == '/') {
+ char *c;
+
item->path = g_strdup_printf("%s%s", mp->path, name);
- else
+
+ /* Folder names may contain characters not valid in a path */
+ for (c = item->path + strlen(mp->path); *c; c++) {
+ if (*c == '/' && c[1] != '/' && c[1] != '\0')
+ continue;
+
+ if (!g_ascii_isalnum(*c) && *c != '_')
+ *c = '_';
+ }
+ } else {
item->path = g_strdup_printf("%s/item%" PRIu64 "",
folder->item->path, uid);
+ }
item->name = g_strdup(name);
item->type = type;
--
2.43.0
next prev parent reply other threads:[~2026-11-22 10:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 10:57 [PATCH BlueZ 0/8] AVRCP browsing fixes, and browsing and cover art in the target role Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 1/8] avrcp: Fix not checking browsing PDU parameter length Simon Mikuda
2026-11-22 18:57 ` AVRCP browsing fixes, and browsing and cover art in the target role bluez.test.bot
2026-11-22 10:57 ` [PATCH BlueZ 2/8] avrcp: Fix listing media players up to item 0xffffffff Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 3/8] avrcp: Fix byte order of ADDRESSED_PLAYER_CHANGED notification Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 4/8] avrcp: Fix byte order of TRACK_CHANGED identifier Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 5/8] avrcp: Fix not browsing a player addressed before it was listed Simon Mikuda
2026-11-22 10:57 ` Simon Mikuda [this message]
2026-11-22 10:57 ` [PATCH BlueZ 7/8] player: Fix missing Name of listed Now Playing items Simon Mikuda
2026-11-22 10:57 ` [PATCH BlueZ 8/8] player: Fix NumberOfItems of Now Playing after its content changed Simon Mikuda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122105731.799090-7-simon.mikuda@streamunlimited.com \
--to=simon.mikuda@streamunlimited.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).