public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/1] shared/shell: Fix SIGSEGV on invalid input
@ 2026-03-19  2:16 Wouter
  2026-03-19  2:16 ` [PATCH BlueZ 1/1] " Wouter
  0 siblings, 1 reply; 7+ messages in thread
From: Wouter @ 2026-03-19  2:16 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Wouter

In `bluetoothctl` when entering a space followed by a tab the CLI
crashes with a segfault. This patch fixes the user input handling.

Wouter (1):
  shared/shell: Fix SIGSEGV on invalid input

 src/shared/shell.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [PATCH BlueZ v2 1/1] shared/shell: Fix SIGSEGV on invalid input
@ 2026-03-19 14:14 Wouter
  2026-03-19 15:54 ` bluez.test.bot
  0 siblings, 1 reply; 7+ messages in thread
From: Wouter @ 2026-03-19 14:14 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Wouter

This fixes a crash when handling "<space><tab>"

==3760495== Invalid read of size 1
==3760495==    at 0x4902187: strcmp (vg_replace_strmem.c:941)
==3760495==    by 0x4067408: menu_completion (shell.c:1126)
==3760495==    by 0x40675DE: shell_completion (shell.c:1177)
==3760495==    by 0x4B267AB: gen_completion_matches (complete.c:1282)
==3760495==    by 0x4B2F8C1: rl_complete_internal (complete.c:2104)
==3760495==    by 0x4B26B52: _rl_dispatch_subseq (readline.c:941)
==3760495==    by 0x4B27B71: readline_internal_char (readline.c:690)
==3760495==    by 0x4B48695: rl_callback_read_char (callback.c:275)
==3760495==    by 0x40655F2: bt_shell_input_line (shell.c:309)
==3760495==    by 0x406577E: input_read (shell.c:343)
==3760495==    by 0x4068CB4: watch_callback (io-glib.c:173)
==3760495==    by 0x49C1F4C: g_main_dispatch (gmain.c:3565)
==3760495==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
---
 src/shared/shell.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index b061f8001..87a8a310d 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1122,6 +1122,9 @@ static char **menu_completion(const struct bt_shell_menu_entry *entry,
 {
 	char **matches = NULL;
 
+	if (argc == 0)
+		return NULL;
+
 	for (; entry->cmd; entry++) {
 		if (strcmp(entry->cmd, input_cmd))
 			continue;
@@ -1147,6 +1150,9 @@ static char **submenu_completion(const char *text, int argc, char *input_cmd)
 	if (data.main != data.menu)
 		return NULL;
 
+	if (!input_cmd)
+		return NULL;
+
 	cmd = strrchr(input_cmd, '.');
 	if (!cmd)
 		return NULL;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-03-19 15:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19  2:16 [PATCH BlueZ 0/1] shared/shell: Fix SIGSEGV on invalid input Wouter
2026-03-19  2:16 ` [PATCH BlueZ 1/1] " Wouter
2026-03-19  4:24   ` bluez.test.bot
2026-03-19 11:08   ` [PATCH BlueZ 1/1] " Bastien Nocera
2026-03-19 11:15     ` Bastien Nocera
2026-03-19 14:10       ` Wouter
  -- strict thread matches above, loose matches on Subject: below --
2026-03-19 14:14 [PATCH BlueZ v2 " Wouter
2026-03-19 15:54 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox