From: Marcus Meissner Date: Tue, 11 Apr 2023 14:05:36 +0000 (+0200) Subject: fixed the sizes passed into snprintf X-Git-Tag: v0.96~27^2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F468%2Fhead;p=thirdparty%2Fmtr.git fixed the sizes passed into snprintf --- diff --git a/ui/report.c b/ui/report.c index 9301480..61f2c74 100644 --- a/ui/report.c +++ b/ui/report.c @@ -140,7 +140,7 @@ void report_close( continue; snprintf(fmt, sizeof(fmt), "%%%ds", data_fields[j].length); - snprintf(buf + len, sizeof(buf), fmt, data_fields[j].title); + snprintf(buf + len, sizeof(buf) - len, fmt, data_fields[j].title); len += data_fields[j].length; } printf("%s\n", buf); @@ -172,10 +172,10 @@ void report_close( /* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */ if (strchr(data_fields[j].format, 'f')) { - snprintf(buf + len, sizeof(buf), data_fields[j].format, + snprintf(buf + len, sizeof(buf) - len, data_fields[j].format, data_fields[j].net_xxx(at) / 1000.0); } else { - snprintf(buf + len, sizeof(buf), data_fields[j].format, + snprintf(buf + len, sizeof(buf) - len, data_fields[j].format, data_fields[j].net_xxx(at)); } len += data_fields[j].length;