From c871174916da0601196d2e1f8ace6a63838e850e Mon Sep 17 00:00:00 2001 From: Don Lewis Date: Mon, 16 May 2016 00:25:24 +0000 Subject: Use strlcpy() instead of strncpy() when copying ifname to ensure that it is NUL terminated. Additional NUL padding is not required for short names. Use sizeof(destination) in a few places instead of IFNAMSIZ. Cast afp->af_ridreq and afp->af_addreq to make the intent of the code more obvious. Reported by: Coverity CID: 1009628, 1009630, 1009631, 1009632, 1009633, 1009635, 1009638 CID: 1009639, 1009640, 1009641, 1009642, 1009643, 1009644, 1009645 CID: 1009646, 1009647, 1010049, 1010050, 1010051, 1010052, 1010053 CID: 1010054, 1011293, 1011294, 1011295, 1011296, 1011297, 1011298 CID: 1011299, 1305821, 1351720, 1351721 MFC after: 1 week --- sbin/ifconfig/ifgre.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sbin/ifconfig/ifgre.c') diff --git a/sbin/ifconfig/ifgre.c b/sbin/ifconfig/ifgre.c index 98d1bf608a6a..36896785a8e2 100644 --- a/sbin/ifconfig/ifgre.c +++ b/sbin/ifconfig/ifgre.c @@ -68,7 +68,7 @@ setifgrekey(const char *val, int dummy __unused, int s, { uint32_t grekey = strtol(val, NULL, 0); - strncpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); + strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name)); ifr.ifr_data = (caddr_t)&grekey; if (ioctl(s, GRESKEY, (caddr_t)&ifr) < 0) warn("ioctl (set grekey)"); -- cgit v1.2.3