summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-04-17 01:05:27 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-04-17 01:05:27 +0000
commit24793e9a7eb16ed4f749b32419154bc2a58bbc1d (patch)
tree2cfe2c9bf7cfb9569244d93dd7825206892dabd7
parent04e3dafbeb0b78f247140314de18c9099a1b2bae (diff)
Improve reading device names from cache
-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;
};
}