]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
coverity: replace unsafe uses of strncpy by strlcpy
authorVincent Bernat <bernat@luffy.cx>
Fri, 22 Nov 2013 22:37:56 +0000 (23:37 +0100)
committerVincent Bernat <bernat@luffy.cx>
Fri, 22 Nov 2013 22:37:56 +0000 (23:37 +0100)
src/daemon/interfaces-linux.c
src/daemon/lldpd.c

index 748d0eb3b7457286691596dcd9a31e4de6adf170..22e9c75291494bc058de3134f07a763ad7715245 100644 (file)
@@ -122,7 +122,7 @@ old_iflinux_is_bridge(struct lldpd *cfg,
                .ifr_data = (char*)&args2
        };
 
-       strncpy(ifr.ifr_name, iface->name, IFNAMSIZ);
+       strlcpy(ifr.ifr_name, iface->name, IFNAMSIZ);
 
        if (ioctl(cfg->g_sock, SIOCDEVPRIVATE, &ifr) < 0)
                /* This can happen with a 64bit kernel and 32bit
@@ -571,7 +571,7 @@ iflinux_handle_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces
                        bmaster = hardware->h_data;
                        memset(bmaster, 0, sizeof(struct bond_master));
                        bmaster->index = master->index;
-                       strncpy(bmaster->name, master->name, IFNAMSIZ);
+                       strlcpy(bmaster->name, master->name, IFNAMSIZ);
                        lldpd_port_cleanup(&hardware->h_lport, 0);
                }
 
index 39d2d04bf7ec6b6496e63338432ddf987b1ef9bd..849cdfc773fe8eccdc982d1c3458d33771e2b5d1 100644 (file)
@@ -714,12 +714,12 @@ lldpd_get_os_release() {
                return NULL;
        }
 
-       while ((fgets(line, 1024, fp) != NULL)) {
+       while ((fgets(line, sizeof(line), fp) != NULL)) {
                key = strtok(line, "=");
                val = strtok(NULL, "=");
 
-               if (strncmp(key, "PRETTY_NAME", 1024) == 0) {
-                       strncpy(release, val, 1024);
+               if (strncmp(key, "PRETTY_NAME", sizeof(line)) == 0) {
+                       strlcpy(release, val, sizeof(line));
                        break;
                }
        }