Skip to content

Commit d74d32f

Browse files
Flavio Ceolinjgl-meta
authored andcommitted
bt: audio: shell: Fix possible buffer overflow
Check the size of the search argument in cmd_mcc_send_search_raw before copying it. Signed-off-by: Flavio Ceolin <[email protected]> (cherry picked from commit 02e70f5)
1 parent af96ed2 commit d74d32f

File tree

1 file changed

+8
-1
lines changed
  • subsys/bluetooth/audio/shell

1 file changed

+8
-1
lines changed

subsys/bluetooth/audio/shell/mcc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1448,9 +1448,16 @@ static int cmd_mcc_send_search_raw(const struct shell *sh, size_t argc,
14481448
char *argv[])
14491449
{
14501450
int result;
1451+
size_t len;
14511452
struct mpl_search search;
14521453

1453-
search.len = strlen(argv[1]);
1454+
len = strlen(argv[1]);
1455+
if (len > sizeof(search.search)) {
1456+
shell_print(sh, "Fail: Invalid argument");
1457+
return -EINVAL;
1458+
}
1459+
1460+
search.len = len;
14541461
memcpy(search.search, argv[1], search.len);
14551462
LOG_DBG("Search string: %s", argv[1]);
14561463

0 commit comments

Comments
 (0)