From 1d2e71b109d907473939864caa5afec86000d58a Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Fri, 17 Jun 2005 12:10:54 +0000 Subject: Replace non-printable characters in device names --- hcid/storage.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'hcid') diff --git a/hcid/storage.c b/hcid/storage.c index 79ec11af..c5f5eaed 100644 --- a/hcid/storage.c +++ b/hcid/storage.c @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -166,7 +167,7 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer, const char *n char filename[PATH_MAX + 1], addr[18], str[249], *buf, *ptr; bdaddr_t bdaddr; struct stat st; - int fd, pos, err = 0; + int i, fd, pos, err = 0; ba2str(local, addr); snprintf(filename, PATH_MAX, "%s/%s/names", STORAGEDIR, addr); @@ -216,7 +217,13 @@ int write_device_name(const bdaddr_t *local, const bdaddr_t *peer, const char *n ftruncate(fd, 0); } - list = list_add(list, peer, name, strlen(name) + 1); + memset(str, 0, sizeof(str)); + strncpy(str, name, 248); + for (i = 0; i < 248 && str[i]; i++) + if (!isprint(str[i])) + str[i] = '.'; + + list = list_add(list, peer, str, strlen(str) + 1); if (!list) { err = -EIO; goto unlock; -- cgit