diff mbox series

[BlueZ,v2] client: add input validation to main()

Message ID 20250303144844.60025-1-r.smirnov@omp.ru (mailing list archive)
State Accepted
Commit 8479c279ea937c12b3091900c2783ca03e468542
Headers show
Series [BlueZ,v2] client: add input validation to main() | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Roman Smirnov March 3, 2025, 2:48 p.m. UTC
An error was found during fuzzing testing. When passing Unicode
characters to bluetoothctl the application crashes in dbus:

dbus[5324]: arguments to dbus_message_iter_append_basic() were
incorrect, assertion "_dbus_check_is_valid_utf8 (*string_p)"
failed in file .../dbus-message.c line 2765.

Check that all characters are written in utf8.

Fixes: https://github.com/bluez/bluez/issues/1118
---
 client/main.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

bluez.test.bot@gmail.com March 3, 2025, 4:12 p.m. UTC | #1
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=939649

---Test result---

Test Summary:
CheckPatch                    PENDING   0.24 seconds
GitLint                       PENDING   0.23 seconds
BuildEll                      PASS      20.40 seconds
BluezMake                     PASS      1500.02 seconds
MakeCheck                     PASS      13.06 seconds
MakeDistcheck                 PASS      160.76 seconds
CheckValgrind                 PASS      215.10 seconds
CheckSmatch                   PASS      283.51 seconds
bluezmakeextell               PASS      98.61 seconds
IncrementalBuild              PENDING   0.27 seconds
ScanBuild                     PASS      874.53 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org March 3, 2025, 5:50 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 3 Mar 2025 17:48:43 +0300 you wrote:
> An error was found during fuzzing testing. When passing Unicode
> characters to bluetoothctl the application crashes in dbus:
> 
> dbus[5324]: arguments to dbus_message_iter_append_basic() were
> incorrect, assertion "_dbus_check_is_valid_utf8 (*string_p)"
> failed in file .../dbus-message.c line 2765.
> 
> [...]

Here is the summary with links:
  - [BlueZ,v2] client: add input validation to main()
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8479c279ea93

You are awesome, thank you!
diff mbox series

Patch

diff --git a/client/main.c b/client/main.c
index feb21a116..6b938da3f 100644
--- a/client/main.c
+++ b/client/main.c
@@ -843,6 +843,18 @@  static gboolean parse_argument(int argc, char *argv[], const char **arg_table,
 	return FALSE;
 }
 
+static int validate_input(int argc, char *argv[])
+{
+	for (int i = 0; i < argc; i++) {
+		if (!strisutf8(argv[i], strlen(argv[i]))) {
+			printf("Invalid character in string: %s\n", argv[i]);
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
 static void cmd_list(int argc, char *argv[])
 {
 	GList *list;
@@ -3299,6 +3311,10 @@  int main(int argc, char *argv[])
 	int timeout;
 	unsigned int timeout_id;
 
+	status = validate_input(argc, argv);
+	if (status)
+		return status;
+
 	bt_shell_init(argc, argv, &opt);
 	bt_shell_set_menu(&main_menu);
 	bt_shell_add_submenu(&advertise_menu);