summaryrefslogtreecommitdiffstats
path: root/tools/hcitool.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/hcitool.c')
-rw-r--r--tools/hcitool.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 5106f664..6da3d3c1 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -316,8 +316,10 @@ static int read_device_name(const bdaddr_t *local, const bdaddr_t *peer, char *n
ptr = buf;
+ memset(str, 0, sizeof(str));
while (sscanf(ptr, "%17s %[^\n]\n%n", addr, str, &pos) != EOF) {
str2ba(addr, &bdaddr);
+ str[sizeof(str) - 1] = '\0';
if (!bacmp(&bdaddr, peer)) {
snprintf(name, 249, "%s", str);
@@ -325,7 +327,10 @@ static int read_device_name(const bdaddr_t *local, const bdaddr_t *peer, char *n
break;
}
+ memset(str, 0, sizeof(str));
ptr += pos;
+ if (ptr - buf >= st.st_size)
+ break;
};
}