Skip to content

Commit

Permalink
bt: audio: shell: Fix possible buffer overflow
Browse files Browse the repository at this point in the history
Check the size of the search argument in cmd_media_set_search
before copying it.

(cherry picked from commit e55af04)

Original-Signed-off-by: Flavio Ceolin <[email protected]>
GitOrigin-RevId: e55af04
Change-Id: Ibb502b3e8cfdc5738564acc063dcf79be66daf40
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/4704779
Tested-by: ChromeOS Prod (Robot) <[email protected]>
Reviewed-by: Fabio Baltieri <[email protected]>
Tested-by: Fabio Baltieri <[email protected]>
Commit-Queue: Fabio Baltieri <[email protected]>
  • Loading branch information
Flavio Ceolin authored and Chromeos LUCI committed Jul 20, 2023
1 parent 0e09d11 commit 784ba3a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion subsys/bluetooth/audio/shell/media_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,9 +1230,16 @@ static int cmd_media_set_search(const struct shell *sh, size_t argc, char *argv[
*/

struct mpl_search search;
size_t len;
int err;

search.len = strlen(argv[1]);
len = strlen(argv[1]);
if (len > sizeof(search.search)) {
shell_print(sh, "Fail: Invalid argument");
return -EINVAL;
}

search.len = len;
memcpy(search.search, argv[1], search.len);
LOG_DBG("Search string: %s", argv[1]);

Expand Down

0 comments on commit 784ba3a

Please sign in to comment.