From 24793e9a7eb16ed4f749b32419154bc2a58bbc1d Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 17 Apr 2005 01:05:27 +0000 Subject: Improve reading device names from cache --- tools/hcitool.c | 5 +++++ 1 file changed, 5 insertions(+) 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; }; } -- cgit