Skip to content

Commit

Permalink
fix: Fix a couple of buffer overrun hazards.
Browse files Browse the repository at this point in the history
Pointed out by @berkakinci.

Fixes esnet#1134.
  • Loading branch information
bmah888 authored and hanvari committed Jul 3, 2021
1 parent b3772db commit 691c474
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/iperf_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -4557,10 +4557,11 @@ iperf_printf(struct iperf_test *test, const char* format, ...)
char linebuffer[1024];
int i = 0;
if (ct) {
i = sprintf(linebuffer, "%s", ct);
i = snprintf(linebuffer, sizeof(linebuffer), "%s", ct);
}
va_start(argp, format);
r = vsnprintf(linebuffer + i, sizeof(linebuffer), format, argp);
r = vsnprintf(linebuffer + i, sizeof(linebuffer) - i, format, argp);
r += i;
va_end(argp);
fprintf(test->outfile, "%s", linebuffer);

Expand Down

0 comments on commit 691c474

Please sign in to comment.