From 28c1cbea975ef1caaac3178ea89984b6b41789b6 Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Mon, 29 Dec 2025 11:02:21 +0000 Subject: [PATCH] Coverity: Fix TAINTED_SCALAR warning --- xrdpapi/connectmon.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/xrdpapi/connectmon.c b/xrdpapi/connectmon.c index 38b5dfc0..1e89e91f 100644 --- a/xrdpapi/connectmon.c +++ b/xrdpapi/connectmon.c @@ -112,11 +112,22 @@ main(int argc, char **argv) log_start_from_param(lc); } - if (argc > 1 && atoi(argv[1]) > 0) + if (argc > 1 && atoi(argv[1]) >= 0) { changes = atoi(argv[1]); + if (changes > 1000) + { + changes = 1000; // Use 0 for more than this + } + } + if (changes > 0) + { + printf("Connection monitor : exiting after %d state changes\n", changes); + } + else + { + printf("Connection monitor\n"); } - printf("Connection monitor : exiting after %d state changes\n", changes); print_current_connection_state(); @@ -128,7 +139,7 @@ main(int argc, char **argv) else { int count = 0; - while (count < changes && result == 0) + while (result == 0) { struct pollfd pollarg = { @@ -139,6 +150,11 @@ main(int argc, char **argv) int pollstat; LRESULT cbresult; + if (changes > 0 && count >= changes) + { + break; + } + if ((pollstat = poll(&pollarg, 1, -1)) < 0) { printf("** Error from poll() : %s\n", strerror(errno));