From d6b542c89e1ba8ca407285c3c1715077d230581f Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Tue, 29 Aug 2017 19:05:45 +0200 Subject: pidstr needs 11 bytes (10 + NULL) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also use %d because index is signed int. Found by compiler: netstats.c:165:23: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=] snprintf(pidstr, 10, "%u", index); ^~~~ In file included from /usr/include/stdio.h:938:0, from firemon.h:24, from netstats.c:20: /usr/include/x86_64-linux-gnu/bits/stdio2.h:64:10: note: ‘__builtin___snprintf_chk’ output between 2 and 11 bytes into a destination of size 10 --- src/firemon/netstats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/firemon/netstats.c') diff --git a/src/firemon/netstats.c b/src/firemon/netstats.c index ad123be50..c68e2e51b 100644 --- a/src/firemon/netstats.c +++ b/src/firemon/netstats.c @@ -161,8 +161,8 @@ static void print_proc(int index, int itv, int col) { } // pid - char pidstr[10]; - snprintf(pidstr, 10, "%u", index); + char pidstr[11]; + snprintf(pidstr, 11, "%d", index); // user char *user = get_user_name(pids[index].uid); -- cgit v1.2.3-54-g00ecf