Skip to content

Commit

Permalink
fixed the sizes passed into snprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
msmeissn committed Apr 11, 2023
1 parent 56fe6c4 commit 5908af4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ui/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5908af4

Please sign in to comment.