Fix a crash that can be triggered by libiperf3 clients that don't use

iperf_parse_arguments().  Basically we need to initialize the
output stream in the iperf_test structure regardless of whether
iperf_parse_arguments() gets called; some programs (in particular
the programs in the examples/ directory and bwctl) don't do this
(and indeed should not need to).

This problem was introduced in the solution for Issue #119; the fix
needs to be merged to any codeline where fixes for Issue #119 go.
This commit is contained in:
Bruce A. Mah 2014-03-20 10:24:25 -07:00
parent 6c03583982
commit 2808a0b6c4

View File

@ -802,7 +802,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
}
}
/* Set logging to a file if specified, otherwise stdout*/
/* Set logging to a file if specified, otherwise use the default (stdout) */
if (test->logfile) {
test->outfile = fopen(test->logfile, "a+");
if (test->outfile == NULL) {
@ -810,9 +810,6 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
return -1;
}
}
else {
test->outfile = stdout;
}
/* Check flag / role compatibility. */
if (test->role == 'c' && server_flag) {
@ -1514,6 +1511,9 @@ iperf_new_test()
}
memset(test->settings, 0, sizeof(struct iperf_settings));
/* By default all output goes to stdout */
test->outfile = stdout;
return test;
}