@@ -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)
Use snprintf to print only valid data. That's the similar change done for ifstat. Signed-off-by: Denis Kirjanov <dkirjanov@suse.de> --- misc/nstat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)