mirror of
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git
synced 2026-01-26 14:13:24 +00:00
nstat: convert sprintf to snprintf
Use snprintf to print only valid data. That's the similar change done for ifstat. Signed-off-by: Denis Kirjanov <dkirjanov@suse.de> Signed-off-by: David Ahern <dsahern@kernel.org>
This commit is contained in:
parent
2f8b36e146
commit
b69e1e0445
@ -483,7 +483,7 @@ static void server_loop(int fd)
|
||||
p.fd = fd;
|
||||
p.events = p.revents = POLLIN;
|
||||
|
||||
sprintf(info_source, "%d.%lu sampling_interval=%d time_const=%d",
|
||||
snprintf(info_source, sizeof(info_source), "%d.%lu sampling_interval=%d time_const=%d",
|
||||
getpid(), (unsigned long)random(), scan_interval/1000, time_constant/1000);
|
||||
|
||||
load_netstat();
|
||||
@ -636,7 +636,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
sun.sun_family = AF_UNIX;
|
||||
sun.sun_path[0] = 0;
|
||||
sprintf(sun.sun_path+1, "nstat%d", getuid());
|
||||
snprintf(sun.sun_path + 1, sizeof(sun.sun_path) - 1, "nstat%d", getuid());
|
||||
|
||||
if (scan_interval > 0) {
|
||||
if (time_constant == 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user