From 8d542d4a9b7c3ead90d709976105c4b70858f183 Mon Sep 17 00:00:00 2001 From: EunBong Song Date: Mon, 7 Aug 2017 15:18:04 -0700 Subject: [PATCH] iperf: Fix data abort in iperf client. Following test cause data abort of iperf client. iperf -s iperf -c 127.0.0.1 iperf -c 127.0.0.1 Data abort can happen when iperf_run_client returns negative value. In this case, iperf calls iperf_free_test -> iperf_client_end -> iperf_free_test. This cause data abort because test is already freed in iperf_free_test however iperf_client_end tries to use test pointer. And also iperf_free_test tries to free again test pointer. This patch re-organize the process this procedure. Change-Id: I0ad6d986cd2457648eb2a99a078b8fa3af9e3ed7 Signed-off-by: EunBong Song --- apps/examples/iperf/iperf_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/examples/iperf/iperf_main.c b/apps/examples/iperf/iperf_main.c index 1f2d112..6d3efa1 100644 --- a/apps/examples/iperf/iperf_main.c +++ b/apps/examples/iperf/iperf_main.c @@ -127,6 +127,7 @@ int iperf_main(int argc, char **argv) goto main_exit; } + if (run(test) < 0) { printf("error - %s\n", iperf_strerror(i_errno)); goto main_exit; @@ -162,11 +163,16 @@ static int run(struct iperf_test *test) break; case 'c': if (iperf_run_client(test) < 0) { + struct iperf_stream *sp; + + iperf_set_send_state(test, IPERF_DONE); close(test->ctrl_sck); - iperf_client_end(test); + SLIST_FOREACH(sp, &test->streams, streams) { + close(sp->socket); + } iperf_free_test(test); printf("error - %s\n", iperf_strerror(i_errno)); - goto run_exit; + exit(1); } break; default: @@ -174,6 +180,5 @@ static int run(struct iperf_test *test) break; } -run_exit: return 0; } -- 2.7.4