]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/rp-pppoe/if.c
Merge pull request #177 from tisj/eap-mschapv2-server
[ppp.git] / pppd / plugins / rp-pppoe / if.c
index 91e9a57dd4024b48cb4ab4276994194763f38be3..225dd567c2e7486c5ef3998c108ac5e8bb18afce 100644 (file)
@@ -30,10 +30,6 @@ static char const RCSID[] =
 #include <linux/if_packet.h>
 #endif
 
-#ifdef HAVE_NET_ETHERNET_H
-#include <net/ethernet.h>
-#endif
-
 #ifdef HAVE_ASM_TYPES_H
 #include <asm/types.h>
 #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);