]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/plugins/rp-pppoe/if.c
Various fixes for errors found by coverity static analysis (#109)
[ppp.git] / pppd / plugins / rp-pppoe / if.c
index 91e9a57dd4024b48cb4ab4276994194763f38be3..07b20b1717ab5e9637a0394e5f83154733a272d7 100644 (file)
@@ -133,7 +133,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 +152,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 +166,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);