Hello Maintainers
This patch fixes assertion in bluetoothctl client process
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.
Thank you in advance for your review.
Warm Regards
Vinit Mehta
Vinit Mehta (1):
mgmt: Fix crash after pair command
client/mgmt.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
--
2.42.0.windows.2
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
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=810016
---Test result---
Test Summary:
CheckPatch FAIL 0.82 seconds
GitLint PASS 0.30 seconds
BuildEll PASS 24.46 seconds
BluezMake PASS 735.10 seconds
MakeCheck PASS 12.45 seconds
MakeDistcheck PASS 154.37 seconds
CheckValgrind PASS 216.05 seconds
CheckSmatch PASS 319.72 seconds
bluezmakeextell PASS 100.78 seconds
IncrementalBuild PASS 667.31 seconds
ScanBuild WARNING 915.38 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v1,1/1] mgmt: Fix crash after pair command
ERROR:OPEN_BRACE: that open brace { should be on the previous line
#117: FILE: client/mgmt.c:853:
+ if(len)
+ {
ERROR:SPACING: space required before the open parenthesis '('
#117: FILE: client/mgmt.c:853:
+ if(len)
WARNING:LONG_LINE: line length of 83 exceeds 80 columns
#122: FILE: client/mgmt.c:858:
+ mgmt_confirm_neg_reply(prompt.index, &prompt.addr);
ERROR:OPEN_BRACE: that open brace { should be on the previous line
#124: FILE: client/mgmt.c:860:
else
+ {
WARNING:LONG_LINE_COMMENT: line length of 87 exceeds 80 columns
#126: FILE: client/mgmt.c:862:
+ /* After pair command, if the user doesn't provide any input on
WARNING:LONG_LINE_COMMENT: line length of 89 exceeds 80 columns
#127: FILE: client/mgmt.c:863:
+ * bluetoothctl CLI interface after receiving the prompt(yes/no),
WARNING:LONG_LINE_COMMENT: line length of 82 exceeds 80 columns
#128: FILE: client/mgmt.c:864:
+ * than subsequent CLI command will trigger a call to DBUS
WARNING:LONG_LINE_COMMENT: line length of 83 exceeds 80 columns
#129: FILE: client/mgmt.c:865:
+ * library function (dbus_message_get_no_reply) with a NULL
WARNING:LONG_LINE_COMMENT: line length of 83 exceeds 80 columns
#130: FILE: client/mgmt.c:866:
+ * message pointer which triggers assertion in DBUS library
WARNING:LONG_LINE_COMMENT: line length of 86 exceeds 80 columns
#131: FILE: client/mgmt.c:867:
+ * causing the bluetoothctl process to crash. The change below
WARNING:LONG_LINE_COMMENT: line length of 82 exceeds 80 columns
#132: FILE: client/mgmt.c:868:
+ * will ensure in case if no input is given by the user, a
WARNING:LONG_LINE_COMMENT: line length of 83 exceeds 80 columns
#133: FILE: client/mgmt.c:869:
+ * conditional check is added to handle this scenario and a
WARNING:LONG_LINE_COMMENT: line length of 84 exceeds 80 columns
#134: FILE: client/mgmt.c:870:
+ * default character ('N') will be passed so as to avoid the
WARNING:BLOCK_COMMENT_STYLE: Block comments use a trailing */ on a separate line
#135: FILE: client/mgmt.c:871:
+ * assertion.*/
/github/workspace/src/src/13492807.patch total: 3 errors, 11 warnings, 37 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/src/13492807.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
client/mgmt.c:872:4: warning: Value stored to 'input' is never read
input = dummy_input;
^ ~~~~~~~~~~~
1 warning generated.
---
Regards,
Linux Bluetooth