summaryrefslogtreecommitdiffstats
path: root/hcid
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2005-08-05 03:26:40 +0000
committerMarcel Holtmann <marcel@holtmann.org>2005-08-05 03:26:40 +0000
commit1a3907a17151a5cdae2d395865a2951090c07ac5 (patch)
tree70c2c06dca09f091eeb9e4e451c56d5640051c55 /hcid
parent8ac83f1424fe8c726aeeccda705c6840d5b31ab9 (diff)
Replace non-printable characters in the device name
Diffstat (limited to 'hcid')
-rw-r--r--hcid/security.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/hcid/security.c b/hcid/security.c
index 108887ce..7dfa4a17 100644
--- a/hcid/security.c
+++ b/hcid/security.c
@@ -33,22 +33,18 @@
#endif
#include <stdio.h>
-#include <stdlib.h>
+#include <errno.h>
+#include <ctype.h>
+#include <fcntl.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <malloc.h>
#include <string.h>
#include <signal.h>
-#include <fcntl.h>
#include <syslog.h>
-#include <errno.h>
-#include <time.h>
-#include <fcntl.h>
#include <time.h>
-
#include <sys/ioctl.h>
#include <sys/socket.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
@@ -308,7 +304,7 @@ static void call_pin_helper(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
struct sigaction sa;
char addr[18], str[255], *pin, name[249];
FILE *pipe;
- int ret, len;
+ int i, ret, len;
/* Run PIN helper in the separate process */
switch (fork()) {
@@ -331,6 +327,11 @@ static void call_pin_helper(int dev, bdaddr_t *sba, struct hci_conn_info *ci)
read_device_name(sba, &ci->bdaddr, name);
//hci_remote_name(dev, &ci->bdaddr, sizeof(name), name, 0);
+ for (i = 0; i < 248 && name[i]; i++)
+ if (!isprint(name[i]))
+ name[i] = '.';
+ name[248] = '\0';
+
ba2str(&ci->bdaddr, addr);
snprintf(str, sizeof(str), "%s %s %s \'%s\'", hcid.pin_helper,
ci->out ? "out" : "in", addr, name);