public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] main: fix bool vs. gboolean type in g_option_context_parse()
@ 2025-12-04 20:38 Pauli Virtanen
  2025-12-04 21:38 ` [BlueZ] " bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Pauli Virtanen @ 2025-12-04 20:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

btd_opts.experimental and testing are bool, not gboolean, which may
cause memory to be clobbered and crash.

Fix with separate variable for cmdline option.

Log:
ERROR: AddressSanitizer: BUS on unknown address
    #0 0x0000005b9914 in queue_find ../src/shared/queue.c:230
    #1 0x00000057c0ff in btd_kernel_experimental_enabled ../src/main.c:721
    #2 0x0000004ff52f in read_exp_features_complete ../src/adapter.c:10230
    #3 0x0000005be40b in request_complete ../src/shared/mgmt.c:306
---
 src/main.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index 558bf2888..61e5ef983 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1330,6 +1330,8 @@ static char *option_noplugin = NULL;
 static char *option_configfile = NULL;
 static gboolean option_compat = FALSE;
 static gboolean option_detach = TRUE;
+static gboolean option_experimental = FALSE;
+static gboolean option_testing = FALSE;
 static gboolean option_version = FALSE;
 
 static void free_options(void)
@@ -1420,9 +1422,9 @@ static GOptionEntry options[] = {
 			"Specify an explicit path to the config file", "FILE"},
 	{ "compat", 'C', 0, G_OPTION_ARG_NONE, &option_compat,
 				"Provide deprecated command line interfaces" },
-	{ "experimental", 'E', 0, G_OPTION_ARG_NONE, &btd_opts.experimental,
+	{ "experimental", 'E', 0, G_OPTION_ARG_NONE, &option_experimental,
 				"Enable experimental D-Bus interfaces" },
-	{ "testing", 'T', 0, G_OPTION_ARG_NONE, &btd_opts.testing,
+	{ "testing", 'T', 0, G_OPTION_ARG_NONE, &option_testing,
 				"Enable testing D-Bus interfaces" },
 	{ "kernel", 'K', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
 				parse_kernel_experimental,
@@ -1464,6 +1466,9 @@ int main(int argc, char *argv[])
 		exit(0);
 	}
 
+	btd_opts.experimental = option_experimental;
+	btd_opts.testing = option_testing;
+
 	umask(0077);
 
 	btd_backtrace_init();
-- 
2.51.1


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

end of thread, other threads:[~2025-12-06  5:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-04 20:38 [PATCH BlueZ] main: fix bool vs. gboolean type in g_option_context_parse() Pauli Virtanen
2025-12-04 21:38 ` [BlueZ] " bluez.test.bot
2025-12-05 15:00 ` [PATCH BlueZ] " patchwork-bot+bluetooth
2025-12-05 15:13 ` Bastien Nocera
2025-12-05 16:30   ` Pauli Virtanen

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