Skip to content

Commit 06ca73d

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

subsys/bluetooth/audio/shell/media_controller.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,9 +1230,16 @@ static int cmd_media_set_search(const struct shell *sh, size_t argc, char *argv[
12301230
*/
12311231

12321232
struct mpl_search search;
1233+
size_t len;
12331234
int err;
12341235

1235-
search.len = strlen(argv[1]);
1236+
len = strlen(argv[1]);
1237+
if (len > sizeof(search.search)) {
1238+
shell_print(sh, "Fail: Invalid argument");
1239+
return -EINVAL;
1240+
}
1241+
1242+
search.len = len;
12361243
memcpy(search.search, argv[1], search.len);
12371244
LOG_DBG("Search string: %s", argv[1]);
12381245

0 commit comments

Comments
 (0)