diff --git a/subsys/bluetooth/host/shell/bt.c b/subsys/bluetooth/host/shell/bt.c index e53e8123aa0..328c6d9d9ff 100644 --- a/subsys/bluetooth/host/shell/bt.c +++ b/subsys/bluetooth/host/shell/bt.c @@ -1769,16 +1769,17 @@ static int cmd_scan_filter_set_addr(const struct shell *sh, size_t argc, { const size_t max_cpy_len = sizeof(scan_filter.addr) - 1; const char *addr_arg = argv[1]; + size_t len = strlen(addr_arg); /* Validate length including null terminator. */ - if (strlen(addr_arg) > max_cpy_len) { + if (len > max_cpy_len) { shell_error(ctx_shell, "Invalid address string: %s\n", addr_arg); return -ENOEXEC; } /* Validate input to check if valid (subset of) BT address */ - for (size_t i = 0; i < strlen(addr_arg); i++) { + for (size_t i = 0; i < len; i++) { const char c = addr_arg[i]; uint8_t tmp;