svn commit: r300281 - stable/10/usr.sbin/rtadvd
Don Lewis
truckman at FreeBSD.org
Fri May 20 07:00:13 UTC 2016
Author: truckman
Date: Fri May 20 07:00:11 2016
New Revision: 300281
URL: https://svnweb.freebsd.org/changeset/base/300281
Log:
MFC r299867
Use strlcpy() instead of strncpy() when copying ifname to ensure
that it is NUL terminated. Additional NUL padding is not required
for short names.
Reported by: Coverity
CID: 974860, 1009972, 1009973
Modified:
stable/10/usr.sbin/rtadvd/config.c
stable/10/usr.sbin/rtadvd/if.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/usr.sbin/rtadvd/config.c
==============================================================================
--- stable/10/usr.sbin/rtadvd/config.c Fri May 20 06:59:38 2016 (r300280)
+++ stable/10/usr.sbin/rtadvd/config.c Fri May 20 07:00:11 2016 (r300281)
@@ -634,7 +634,7 @@ getconfig_free_pfx:
exit(1);
}
memset(&ndi, 0, sizeof(ndi));
- strncpy(ndi.ifname, ifi->ifi_ifname, sizeof(ndi.ifname));
+ strlcpy(ndi.ifname, ifi->ifi_ifname, sizeof(ndi.ifname));
if (ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&ndi) < 0)
syslog(LOG_INFO, "<%s> ioctl:SIOCGIFINFO_IN6 at %s: %s",
__func__, ifi->ifi_ifname, strerror(errno));
Modified: stable/10/usr.sbin/rtadvd/if.c
==============================================================================
--- stable/10/usr.sbin/rtadvd/if.c Fri May 20 06:59:38 2016 (r300280)
+++ stable/10/usr.sbin/rtadvd/if.c Fri May 20 07:00:11 2016 (r300281)
@@ -388,7 +388,7 @@ update_ifinfo_nd_flags(struct ifinfo *if
}
/* ND flags */
memset(&nd, 0, sizeof(nd));
- strncpy(nd.ifname, ifi->ifi_ifname,
+ strlcpy(nd.ifname, ifi->ifi_ifname,
sizeof(nd.ifname));
error = ioctl(s, SIOCGIFINFO_IN6, (caddr_t)&nd);
if (error) {
@@ -517,7 +517,7 @@ update_ifinfo(struct ifilist_head_t *ifi
if (ifi->ifi_phymtu == 0) {
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_addr.sa_family = AF_INET6;
- strncpy(ifr.ifr_name, ifi->ifi_ifname,
+ strlcpy(ifr.ifr_name, ifi->ifi_ifname,
sizeof(ifr.ifr_name));
error = ioctl(s, SIOCGIFMTU, (caddr_t)&ifr);
if (error) {
More information about the svn-src-stable
mailing list