Skip to content

Commit 1767621

Browse files
Thalleynashif
authored andcommitted
Bluetooth: Shell: Change strcpy to strncpy for addr copy
When copying the address in cmd_scan_filter_set_addr we now use strncpy to not copy more bytes than what fits. This should already have been fixed with a check earlier in the function, but coverity still complains. Signed-off-by: Emil Gydesen <[email protected]>
1 parent 4d854a5 commit 1767621

File tree

1 file changed

+2
-2
lines changed
  • subsys/bluetooth/shell

1 file changed

+2
-2
lines changed

subsys/bluetooth/shell/bt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static struct bt_auto_connect {
136136
static struct bt_scan_filter {
137137
char name[NAME_LEN];
138138
bool name_set;
139-
char addr[18]; /* fits xx:xx:xx:xx:xx:xx\0 */
139+
char addr[BT_ADDR_STR_LEN];
140140
bool addr_set;
141141
int8_t rssi;
142142
bool rssi_set;
@@ -1293,7 +1293,7 @@ static int cmd_scan_filter_set_addr(const struct shell *sh, size_t argc,
12931293
}
12941294
}
12951295

1296-
strcpy(scan_filter.addr, addr_arg);
1296+
strncpy(scan_filter.addr, addr_arg, sizeof(scan_filter.addr));
12971297
scan_filter.addr_set = true;
12981298

12991299
return 0;

0 commit comments

Comments
 (0)