From 78aef75cf2c27a278ffe442c924d830d42fba14f Mon Sep 17 00:00:00 2001 From: DavidBar-On Date: Tue, 15 Jul 2025 20:56:43 +0300 Subject: [PATCH 1/2] Fix for 3 minor issues (unrelated to each other) --- src/iperf_api.c | 2 +- src/iperf_error.c | 3 +++ src/iperf_locale.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index f7110a0eb..ab3eec431 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1811,7 +1811,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) #endif //HAVE_SSL // File cannot be transferred using UDP because of the UDP packets header (packet number, etc.) - if(test->role == 'c' && test->diskfile_name != (char*) 0 && test->protocol->id == Pudp) { + if (test->mode != RECEIVER && test->diskfile_name != (char*) 0 && test->protocol->id == Pudp) { i_errno = IEUDPFILETRANSFER; return -1; } diff --git a/src/iperf_error.c b/src/iperf_error.c index f76ad5f21..24f706cb9 100644 --- a/src/iperf_error.c +++ b/src/iperf_error.c @@ -482,6 +482,9 @@ iperf_strerror(int int_errno) case IETOTALRATE: snprintf(errstr, len, "total required bandwidth is larger than server limit"); break; + case IETOTALINTERVAL: + snprintf(errstr, len, "invalid time interval for calculating average data rate"); + break; case IESKEWTHRESHOLD: snprintf(errstr, len, "skew threshold must be a positive number"); break; diff --git a/src/iperf_locale.c b/src/iperf_locale.c index c59fd116b..f3e4d5430 100644 --- a/src/iperf_locale.c +++ b/src/iperf_locale.c @@ -308,7 +308,7 @@ const char test_start_bytes[] = "Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %"PRIuFAST64" bytes to send, tos %d\n"; const char test_start_blocks[] = -"Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %"PRIuFAST64" bytes to send, tos %d\n"; +"Starting Test: protocol: %s, %d streams, %d byte blocks, omitting %d seconds, %"PRIuFAST64" blocks to send, tos %d\n"; /* ------------------------------------------------------------------- From 48acc2efa3020aeaf25431fa18315be65d96a8ed Mon Sep 17 00:00:00 2001 From: DavidBar-On Date: Wed, 27 Aug 2025 16:31:21 +0300 Subject: [PATCH 2/2] Do not allow UDP file transfer in all cases --- src/iperf_api.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index ab3eec431..257acb84a 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1810,8 +1810,12 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) #endif //HAVE_SSL - // File cannot be transferred using UDP because of the UDP packets header (packet number, etc.) - if (test->mode != RECEIVER && test->diskfile_name != (char*) 0 && test->protocol->id == Pudp) { + /* + * File cannot be transferred using UDP because of the UDP packets + * header (packet number, etc.). Specifying Pudp here implies this is + * on the client side. + */ + if (test->diskfile_name != (char*) 0 && test->protocol->id == Pudp) { i_errno = IEUDPFILETRANSFER; return -1; } @@ -2445,8 +2449,17 @@ get_parameters(struct iperf_test *test) if ((j_p = iperf_cJSON_GetObjectItemType(j, "tcp", cJSON_True)) != NULL) set_protocol(test, Ptcp); - if ((j_p = iperf_cJSON_GetObjectItemType(j, "udp", cJSON_True)) != NULL) - set_protocol(test, Pudp); + if ((j_p = iperf_cJSON_GetObjectItemType(j, "udp", cJSON_True)) != NULL) { + /* Disallow UDP transfers if we already are to/from a file */ + if (test->diskfile_name != NULL) { + i_errno = IEUDPFILETRANSFER; + r = -1; + } + else { + /* Not to/from a file, set UDP protocol as intended*/ + set_protocol(test, Pudp); + } + } if ((j_p = iperf_cJSON_GetObjectItemType(j, "sctp", cJSON_True)) != NULL) set_protocol(test, Psctp); if ((j_p = iperf_cJSON_GetObjectItemType(j, "omit", cJSON_Number)) != NULL)