X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;ds=sidebyside;f=pppd%2Fplugins%2Frp-pppoe%2Fif.c;h=225dd567c2e7486c5ef3998c108ac5e8bb18afce;hb=61821b9b6106a1e834ce14783a0b03b8c5301328;hp=91e9a57dd4024b48cb4ab4276994194763f38be3;hpb=427e3d851c86e35655e14f1dfa9c831a8fab94d9;p=ppp.git diff --git a/pppd/plugins/rp-pppoe/if.c b/pppd/plugins/rp-pppoe/if.c index 91e9a57..225dd56 100644 --- a/pppd/plugins/rp-pppoe/if.c +++ b/pppd/plugins/rp-pppoe/if.c @@ -30,10 +30,6 @@ static char const RCSID[] = #include #endif -#ifdef HAVE_NET_ETHERNET_H -#include -#endif - #ifdef HAVE_ASM_TYPES_H #include #endif @@ -133,7 +129,7 @@ openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr) /* 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); @@ -152,7 +148,7 @@ openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr) } /* 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) { @@ -166,7 +162,7 @@ openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr) 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);