From 1c47430238df9457d4dcef1cbe01ba4cf15b2b6b Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sat, 16 Apr 2005 23:37:15 +0000 Subject: Add more data checks --- hcid/storage.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'hcid') diff --git a/hcid/storage.c b/hcid/storage.c index 0d42d680..dad0c366 100644 --- a/hcid/storage.c +++ b/hcid/storage.c @@ -219,8 +219,10 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer, const char *n list_foreach(list, temp) { ba2str(&temp->bdaddr, addr); - snprintf(buf, 300, "%s %s\n", addr, temp->data); - write(fd, buf, strlen(buf)); + if (temp->data && temp->size > 0) { + snprintf(buf, 300, "%s %s\n", addr, temp->data); + write(fd, buf, strlen(buf)); + } } unlock: @@ -294,8 +296,10 @@ int write_link_key(const bdaddr_t *local, const bdaddr_t *peer, const unsigned c list_foreach(list, temp) { ba2str(&temp->bdaddr, addr); - snprintf(buf, 100, "%s %s\n", addr, temp->data); - write(fd, buf, strlen(buf)); + if (temp->data && temp->size > 0) { + snprintf(buf, 100, "%s %s\n", addr, temp->data); + write(fd, buf, strlen(buf)); + } } unlock: -- cgit