]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - misc/lnstat_util.c
ll_map: Add function to remove link cache entry by index
[mirror_iproute2.git] / misc / lnstat_util.c
index cc54598fe1bef3f6e7e022f149f05a5ced693521..c2dc42ec1ff12a4848691d2e1ea2b642f0aa9631 100644 (file)
@@ -150,7 +150,8 @@ static int lnstat_scan_compat_rtstat_fields(struct lnstat_file *lf)
 {
        char buf[FGETS_BUF_SIZE];
 
-       strncpy(buf, RTSTAT_COMPAT_LINE, sizeof(buf)-1);
+       strncpy(buf, RTSTAT_COMPAT_LINE, sizeof(buf) - 1);
+       buf[sizeof(buf) - 1] = '\0';
 
        return __lnstat_scan_fields(lf, buf);
 }
@@ -180,11 +181,8 @@ static struct lnstat_file *alloc_and_open(const char *path, const char *file)
        }
 
        /* initialize */
-       /* de->d_name is guaranteed to be <= NAME_MAX */
-       strcpy(lf->basename, file);
-       strcpy(lf->path, path);
-       strcat(lf->path, "/");
-       strcat(lf->path, lf->basename);
+       snprintf(lf->basename, sizeof(lf->basename), "%s", file);
+       snprintf(lf->path, sizeof(lf->path), "%s/%s", path, file);
 
        /* initialize to default */
        lf->interval.tv_sec = 1;