tools: Fix compiler warning from wrong array size
diff --git a/tools/bneptest.c b/tools/bneptest.c
index 1404252..a7d5815 100644
--- a/tools/bneptest.c
+++ b/tools/bneptest.c
@@ -89,7 +89,7 @@
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, bridge, IFNAMSIZ - 1);
+ strncpy(ifr.ifr_name, bridge, IFNAMSIZ);
ifr.ifr_data = (char *) args;
if (ioctl(sk, SIOCDEVPRIVATE, &ifr) < 0) {
diff --git a/tools/btmgmt.c b/tools/btmgmt.c
index f60bb8b..ef1a393 100644
--- a/tools/btmgmt.c
+++ b/tools/btmgmt.c
@@ -2293,7 +2293,7 @@
strncpy((char *) cp.name, argv[1], HCI_MAX_NAME_LENGTH);
if (argc > 2)
strncpy((char *) cp.short_name, argv[2],
- MGMT_MAX_SHORT_NAME_LENGTH);
+ MGMT_MAX_SHORT_NAME_LENGTH - 1);
if (mgmt_send(mgmt, MGMT_OP_SET_LOCAL_NAME, index, sizeof(cp), &cp,
name_rsp, NULL, NULL) == 0) {
diff --git a/tools/btproxy.c b/tools/btproxy.c
index ae0ff74..58fa958 100644
--- a/tools/btproxy.c
+++ b/tools/btproxy.c
@@ -629,7 +629,7 @@
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
- strncpy(addr.sun_path, path, len);
+ strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1);
if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
perror("Failed to bind Unix server socket");
diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c
index a76b448..bb0d51e 100644
--- a/tools/hciattach_ath3k.c
+++ b/tools/hciattach_ath3k.c
@@ -499,7 +499,7 @@
}
#define PATCH_LOC_KEY "DA:"
-#define PATCH_LOC_STRING_LEN 8
+#define PATCH_LOC_STRING_LEN (8 + 237)
static int ps_patch_download(int fd, FILE *stream)
{
char byte[3];
diff --git a/tools/hciattach_st.c b/tools/hciattach_st.c
index 85a2e08..b34964c 100644
--- a/tools/hciattach_st.c
+++ b/tools/hciattach_st.c
@@ -120,7 +120,7 @@
{
DIR *dir;
struct dirent *d;
- char pathname[PATH_MAX], filename[NAME_MAX + 2], prefix[20];
+ char pathname[PATH_MAX], filename[PATH_MAX + NAME_MAX + 1], prefix[20];
unsigned char cmd[256];
unsigned char buf[256];
uint8_t seqnum = 0;
diff --git a/tools/test-runner.c b/tools/test-runner.c
index fb8f7e2..0a298dc 100644
--- a/tools/test-runner.c
+++ b/tools/test-runner.c
@@ -51,7 +51,7 @@
#define WAIT_ANY (-1)
#endif
-#define CMDLINE_MAX 2048
+#define CMDLINE_MAX (2048 * 10)
static const char *own_binary;
static char **test_argv;
@@ -243,9 +243,9 @@
strcat(cwd, "/");
if (own_binary[0] == '/')
- snprintf(initcmd, sizeof(initcmd), "%s", own_binary);
+ snprintf(initcmd, sizeof(initcmd) + 1, "%s", own_binary);
else
- snprintf(initcmd, sizeof(initcmd), "%s/%s", cwd, own_binary);
+ snprintf(initcmd, sizeof(initcmd) + 1, "%s/%s", cwd, own_binary);
pos = snprintf(testargs, sizeof(testargs), "%s", test_argv[0]);