From b5eb3a42f4c7d62dce0652efbb9ca6f090df7498 Mon Sep 17 00:00:00 2001 From: David Bar-On Date: Sat, 23 Mar 2024 09:48:03 +0200 Subject: [PATCH] Fix issue 1662 - not allow negative test duration (with rebase and changes per reviewer comments) --- src/iperf_api.c | 2 +- src/iperf_error.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index a296780a1..02b34e5f5 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1313,7 +1313,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv) break; case 't': test->duration = atoi(optarg); - if (test->duration > MAX_TIME) { + if (test->duration > MAX_TIME || test->duration < 0) { i_errno = IEDURATION; return -1; } diff --git a/src/iperf_error.c b/src/iperf_error.c index 6426554cf..231f0025e 100644 --- a/src/iperf_error.c +++ b/src/iperf_error.c @@ -166,7 +166,7 @@ iperf_strerror(int int_errno) snprintf(errstr, len, "some option you are trying to set is client only"); break; case IEDURATION: - snprintf(errstr, len, "test duration too long (maximum = %d seconds)", MAX_TIME); + snprintf(errstr, len, "test duration valid values are 0 to %d seconds", MAX_TIME); break; case IENUMSTREAMS: snprintf(errstr, len, "number of parallel streams too large (maximum = %d)", MAX_STREAMS);