From 2808a0b6c4c6dbca4bdf3f5ecf723c57a8f67640 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Thu, 20 Mar 2014 10:24:25 -0700 Subject: [PATCH] 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. --- src/iperf_api.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index 50b9425..fba928c 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -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; }