diff options
author | Reiner Herrmann <reiner@reiner-h.de> | 2017-08-29 19:05:45 +0200 |
---|---|---|
committer | Reiner Herrmann <reiner@reiner-h.de> | 2017-08-29 19:10:27 +0200 |
commit | d6b542c89e1ba8ca407285c3c1715077d230581f (patch) | |
tree | 127dc8a700f71d37394d620baedddec81a36ea83 /src/firemon/netstats.c | |
parent | Fix pointer dereference (diff) | |
download | firejail-d6b542c89e1ba8ca407285c3c1715077d230581f.tar.gz firejail-d6b542c89e1ba8ca407285c3c1715077d230581f.tar.zst firejail-d6b542c89e1ba8ca407285c3c1715077d230581f.zip |
pidstr needs 11 bytes (10 + NULL)
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
Diffstat (limited to 'src/firemon/netstats.c')
-rw-r--r-- | src/firemon/netstats.c | 4 |
1 files changed, 2 insertions, 2 deletions
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) { | |||
161 | } | 161 | } |
162 | 162 | ||
163 | // pid | 163 | // pid |
164 | char pidstr[10]; | 164 | char pidstr[11]; |
165 | snprintf(pidstr, 10, "%u", index); | 165 | snprintf(pidstr, 11, "%d", index); |
166 | 166 | ||
167 | // user | 167 | // user |
168 | char *user = get_user_name(pids[index].uid); | 168 | char *user = get_user_name(pids[index].uid); |