]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
misc: avoid snprintf warnings in ss and nstat
authorStephen Hemminger <stephen@networkplumber.org>
Mon, 19 Mar 2018 23:23:18 +0000 (16:23 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 29 Mar 2018 15:32:43 +0000 (08:32 -0700)
Gcc 8 checks that target buffer is big enough.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
misc/nstat.c
misc/ss.c

index a4dd405d43a93e86e712475eb3b9e3e733bee839..433a1f483be3fecf5e56b988b1ca40ae2af45004 100644 (file)
@@ -178,12 +178,12 @@ static int count_spaces(const char *line)
 
 static void load_ugly_table(FILE *fp)
 {
-       char buf[4096];
+       char buf[2048];
        struct nstat_ent *db = NULL;
        struct nstat_ent *n;
 
        while (fgets(buf, sizeof(buf), fp) != NULL) {
-               char idbuf[sizeof(buf)];
+               char idbuf[4096];
                int  off;
                char *p;
                int count1, count2, skip = 0;
index fc8e2a0d719fdf8891d19665f72b521d34c5b2f6..76fca3fb711c5e424e25b965133075eadcd84c64 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -4093,7 +4093,7 @@ static int netlink_show_one(struct filter *f,
 
                if (!pid) {
                        done = 1;
-                       strncpy(procname, "kernel", 6);
+                       strncpy(procname, "kernel", 7);
                } else if (pid > 0) {
                        FILE *fp;