From: Stephen Hemminger Date: Mon, 19 Mar 2018 23:23:18 +0000 (-0700) Subject: misc: avoid snprintf warnings in ss and nstat X-Git-Tag: v4.16.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da8034a01904b7f8ed5a96624d06f56b8d3e4afd;p=thirdparty%2Fiproute2.git misc: avoid snprintf warnings in ss and nstat Gcc 8 checks that target buffer is big enough. Signed-off-by: Stephen Hemminger --- diff --git a/misc/nstat.c b/misc/nstat.c index a4dd405d4..433a1f483 100644 --- a/misc/nstat.c +++ b/misc/nstat.c @@ -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; diff --git a/misc/ss.c b/misc/ss.c index fc8e2a0d7..76fca3fb7 100644 --- 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;