summaryrefslogtreecommitdiff
path: root/lib/libbluetooth/bt_dev.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2019-10-03 17:10:16 +0000
committerchristos <christos@NetBSD.org>2019-10-03 17:10:16 +0000
commit94071a989e6695cc3e76eef3409e80ab4ff194cd (patch)
treea50b71fdc64058c73615e87d7dd2ae89fa73f513 /lib/libbluetooth/bt_dev.c
parent65b295791ff69e8dc46f8bd08fcd66b23c948d75 (diff)
Use strlcpy to NUL terminate the name string here. The kernel already
uses strlcpy() to set values in this field. We leave the kernel's strncmp() alone to maintain compatibility.
Diffstat (limited to 'lib/libbluetooth/bt_dev.c')
-rw-r--r--lib/libbluetooth/bt_dev.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/libbluetooth/bt_dev.c b/lib/libbluetooth/bt_dev.c
index 607d4106180..976905f2848 100644
--- a/lib/libbluetooth/bt_dev.c
+++ b/lib/libbluetooth/bt_dev.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bt_dev.c,v 1.3 2010/11/22 19:59:04 plunky Exp $ */
+/* $NetBSD: bt_dev.c,v 1.4 2019/10/03 17:10:16 christos Exp $ */
/*-
* Copyright (c) 2009 Iain Hibbert
@@ -59,7 +59,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: bt_dev.c,v 1.3 2010/11/22 19:59:04 plunky Exp $");
+__RCSID("$NetBSD: bt_dev.c,v 1.4 2019/10/03 17:10:16 christos Exp $");
#include <sys/event.h>
#include <sys/ioctl.h>
@@ -92,7 +92,7 @@ bt_devaddr(const char *name, bdaddr_t *addr)
return bt_devname(NULL, addr);
memset(&btr, 0, sizeof(btr));
- strncpy(btr.btr_name, name, HCI_DEVNAME_SIZE);
+ strlcpy(btr.btr_name, name, HCI_DEVNAME_SIZE);
s = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
if (s == -1)
@@ -781,7 +781,7 @@ bt__devinfo(int s, const char *name, struct bt_devinfo *info)
struct btreq btr;
memset(&btr, 0, sizeof(btr));
- strncpy(btr.btr_name, name, HCI_DEVNAME_SIZE);
+ strlcpy(btr.btr_name, name, HCI_DEVNAME_SIZE);
if (ioctl(s, SIOCGBTINFO, &btr) == -1)
return -1;