Use strlcpy() instead of strncpy() when copying ifname to ensure
that it is NUL terminated. Additional NUL padding is not required for short names. MFC after: 1 week
This commit is contained in:
parent
7b06334915
commit
8afa1c3d7a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=299867
@ -640,7 +640,7 @@ getconfig(struct ifinfo *ifi)
|
||||
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));
|
||||
|
@ -387,7 +387,7 @@ update_ifinfo_nd_flags(struct ifinfo *ifi)
|
||||
}
|
||||
/* 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) {
|
||||
@ -516,7 +516,7 @@ update_ifinfo(struct ifilist_head_t *ifi_head, int ifindex)
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user