avoid strcpy. trunk
authorchristos <christos@NetBSD.org>
Sat, 12 Oct 2019 17:50:56 +0000
branchtrunk
changeset 455273 9056833a3270
parent 455272 28ceeeac1d62
child 455274 1486be8fc11f
avoid strcpy.
usr.bin/btpin/btpin.c
--- a/usr.bin/btpin/btpin.c	Sat Oct 12 17:26:26 2019 +0000
+++ b/usr.bin/btpin/btpin.c	Sat Oct 12 17:50:56 2019 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: btpin.c,v 1.7 2017/12/21 09:04:34 plunky Exp $	*/
+/*	$NetBSD: btpin.c,v 1.8 2019/10/12 17:50:56 christos Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -33,7 +33,7 @@
 
 #include <sys/cdefs.h>
 __COPYRIGHT("@(#) Copyright (c) 2006 Itronix, Inc.  All rights reserved.");
-__RCSID("$NetBSD: btpin.c,v 1.7 2017/12/21 09:04:34 plunky Exp $");
+__RCSID("$NetBSD: btpin.c,v 1.8 2019/10/12 17:50:56 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/un.h>
@@ -132,8 +132,11 @@
 	} else {
 		if (len != -1)
 			usage();
+		len = strlen(pin);
+		if (len > HCI_PIN_SIZE)
+			len = HCI_PIN_SIZE;
 
-		strncpy((char *)rp.pin, pin, HCI_PIN_SIZE);
+		memcpy(rp.pin, pin, len);
 	}
 
 	s = socket(PF_LOCAL, SOCK_STREAM, 0);