Skip to content

Commit

Permalink
Bluetooth: BAP: Fix off-by-one in shell cmd add_broadcast_id
Browse files Browse the repository at this point in the history
The arguments in the shell start from [1] as [0] is the command
itself.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley authored and nashif committed May 26, 2023
1 parent 75637bd commit 527591a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions subsys/bluetooth/audio/shell/bap_broadcast_assistant.c
Expand Up @@ -600,7 +600,7 @@ static int cmd_bap_broadcast_assistant_add_broadcast_id(const struct shell *sh,
return -ENOEXEC;
}

broadcast_id = shell_strtoul(argv[0], 0, &err);
broadcast_id = shell_strtoul(argv[1], 0, &err);
if (err != 0) {
shell_error(sh, "failed to parse broadcast_id: %d", err);

Expand All @@ -611,7 +611,7 @@ static int cmd_bap_broadcast_assistant_add_broadcast_id(const struct shell *sh,
return -ENOEXEC;
}

pa_sync = shell_strtoul(argv[1], 0, &err);
pa_sync = shell_strtoul(argv[2], 0, &err);
if (err != 0) {
shell_error(sh, "failed to parse pa_sync: %d", err);

Expand All @@ -623,8 +623,8 @@ static int cmd_bap_broadcast_assistant_add_broadcast_id(const struct shell *sh,
}

/* TODO: Support multiple subgroups */
if (argc > 2) {
const unsigned long bis_sync = shell_strtoul(argv[2], 0, &err);
if (argc > 3) {
const unsigned long bis_sync = shell_strtoul(argv[3], 0, &err);

if (err != 0) {
shell_error(sh, "failed to parse bis_sync: %d", err);
Expand All @@ -639,9 +639,8 @@ static int cmd_bap_broadcast_assistant_add_broadcast_id(const struct shell *sh,
subgroup.bis_sync = bis_sync;
}

if (argc > 3) {
subgroup.metadata_len = hex2bin(argv[3], strlen(argv[3]),
subgroup.metadata,
if (argc > 4) {
subgroup.metadata_len = hex2bin(argv[4], strlen(argv[4]), subgroup.metadata,
sizeof(subgroup.metadata));

if (subgroup.metadata_len == 0U) {
Expand Down

0 comments on commit 527591a

Please sign in to comment.