Skip to content

Commit

Permalink
Bluetooth: Shell: Fix off-by-one in address length validation
Browse files Browse the repository at this point in the history
Fixes Coverity defect id 248346.

Signed-off-by: Aleksander Wasaznik <[email protected]>
  • Loading branch information
alwa-nordic authored and carlescufi committed Apr 26, 2022
1 parent a796927 commit 77ad017
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions subsys/bluetooth/shell/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,8 @@ static int cmd_scan_filter_set_addr(const struct shell *sh, size_t argc,
{
const char *addr_arg = argv[1];

/* Validate length */
if (strlen(addr_arg) > sizeof(scan_filter.addr)) {
/* Validate length including null terminator. */
if (strlen(addr_arg) >= sizeof(scan_filter.addr)) {
shell_error(ctx_shell, "Invalid address string: %s\n",
addr_arg);
return -ENOEXEC;
Expand Down

0 comments on commit 77ad017

Please sign in to comment.