From: Vinit Mehta <vinit.mehta@nxp.com>
To: linux-bluetooth@vger.kernel.org
Cc: devyani.godbole@nxp.com, nitin.jadhav@nxp.com
Subject: [PATCH BlueZ v1 1/1] mgmt: Fix crash after pair command
Date: Thu, 14 Dec 2023 16:33:38 +0530 [thread overview]
Message-ID: <20231214110339.1763-2-vinit.mehta@nxp.com> (raw)
In-Reply-To: <20231214110339.1763-1-vinit.mehta@nxp.com>
After pair command, if the user doesn't provide any input on bluetoothctl
CLI interface after receiving the prompt(yes/no) below crash is observed:
dbus[782]: arguments to dbus_message_get_no_reply() were incorrect,
assertion "message != NULL" failed in file
/usr/src/debug/dbus/1.14.10-r0/dbus/dbus-message.c line 3250.
This is normally a bug in some application using the D-Bus library.
/usr/lib/libc.so.6(+0x27534) [0xffffa1b67534]
/usr/lib/libc.so.6(__libc_start_main+0x9c) [0xffffa1b6760c]
bluetoothctl(+0x188f0) [0xaaaac9c088f0]
Aborted (core dumped)
---
client/mgmt.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/client/mgmt.c b/client/mgmt.c
index c056d018a..940e25f3c 100644
--- a/client/mgmt.c
+++ b/client/mgmt.c
@@ -54,6 +54,7 @@ static uint16_t mgmt_index = MGMT_INDEX_NONE;
static bool discovery = false;
static bool resolve_names = true;
+static const char *dummy_input = "N";
static struct {
uint16_t index;
@@ -849,10 +850,28 @@ static void prompt_input(const char *input, void *user_data)
&prompt.addr);
break;
case MGMT_EV_USER_CONFIRM_REQUEST:
- if (input[0] == 'y' || input[0] == 'Y')
- mgmt_confirm_reply(prompt.index, &prompt.addr);
+ if(len)
+ {
+ if (input[0] == 'y' || input[0] == 'Y')
+ mgmt_confirm_reply(prompt.index, &prompt.addr);
+ else
+ mgmt_confirm_neg_reply(prompt.index, &prompt.addr);
+ }
else
+ {
+ /* After pair command, if the user doesn't provide any input on
+ * bluetoothctl CLI interface after receiving the prompt(yes/no),
+ * than subsequent CLI command will trigger a call to DBUS
+ * library function (dbus_message_get_no_reply) with a NULL
+ * message pointer which triggers assertion in DBUS library
+ * causing the bluetoothctl process to crash. The change below
+ * will ensure in case if no input is given by the user, a
+ * conditional check is added to handle this scenario and a
+ * default character ('N') will be passed so as to avoid the
+ * assertion.*/
+ input = dummy_input;
mgmt_confirm_neg_reply(prompt.index, &prompt.addr);
+ }
break;
}
}
--
2.42.0.windows.2
next prev parent reply other threads:[~2023-12-14 11:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-14 11:03 [PATCH BlueZ v1 0/1] mgmt: Fix crash after pair command Vinit Mehta
2023-12-14 11:03 ` Vinit Mehta [this message]
2023-12-14 12:05 ` bluez.test.bot
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=20231214110339.1763-2-vinit.mehta@nxp.com \
--to=vinit.mehta@nxp.com \
--cc=devyani.godbole@nxp.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=nitin.jadhav@nxp.com \
/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).