Module Name:    src
Committed By:   christos
Date:           Thu Oct  3 17:10:16 UTC 2019

Modified Files:
        src/lib/libbluetooth: bt_dev.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libbluetooth/bt_dev.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libbluetooth/bt_dev.c
diff -u src/lib/libbluetooth/bt_dev.c:1.3 src/lib/libbluetooth/bt_dev.c:1.4
--- src/lib/libbluetooth/bt_dev.c:1.3	Mon Nov 22 14:59:04 2010
+++ src/lib/libbluetooth/bt_dev.c	Thu Oct  3 13:10:16 2019
@@ -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 *a
 		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, str
 	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;

Reply via email to