/* Fill in hardware address */
if (hwaddr) {
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) {
error("Can't get hardware address for %s: %m", ifname);
close(fd);
}
/* Sanity check on MTU */
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(fd, SIOCGIFMTU, &ifr) < 0) {
error("Can't get MTU for %s: %m", ifname);
} else if (ifr.ifr_mtu < ETH_DATA_LEN) {
sa.sll_family = AF_PACKET;
sa.sll_protocol = htons(type);
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+ strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(fd, SIOCGIFINDEX, &ifr) < 0) {
error("Could not get interface index for %s: %m", ifname);
close(fd);