summaryrefslogtreecommitdiffstats
path: root/hcid/storage.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-06-17 12:10:54 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-06-17 12:10:54 +0000
commit1d2e71b109d907473939864caa5afec86000d58a (patch)
treea96b3aa56635732e0ed8fac4dcb09edca0fb76d6 /hcid/storage.c
parent3257d9b3a8f59561960c75f310fea33d23858024 (diff)
Replace non-printable characters in device names
Diffstat (limited to 'hcid/storage.c')
-rw-r--r--hcid/storage.c11
1 files changed, 9 insertions, 2 deletions
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 <stdio.h>
#include <errno.h>
+#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <malloc.h>
@@ -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;