From 313216443aa63b2b77476f3e9e93e7f62dcca246 Mon Sep 17 00:00:00 2001 From: Alejandro Homs Puron Date: Tue, 19 Oct 2021 09:17:44 +0200 Subject: [PATCH] slsDetectorServer: fix checks on UDP destination entry range --- .../slsDetectorServer/src/slsDetectorServer_funcs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c index d69e14b36..353c3ab4b 100644 --- a/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c +++ b/slsDetectorServers/slsDetectorServer/src/slsDetectorServer_funcs.c @@ -8966,12 +8966,12 @@ int get_dest_udp_list(int file_des) { #if !defined(EIGERD) && !defined(JUNGFRAUD) functionNotImplemented(); #else - if (arg > MAX_UDP_DESTINATION) { + if (arg >= MAX_UDP_DESTINATION) { ret = FAIL; sprintf( mess, "Could not set udp destination. Invalid entry. Options: 0 - %d\n", - MAX_UDP_DESTINATION); + MAX_UDP_DESTINATION - 1); LOG(logERROR, (mess)); } else { retvals[0] = arg; @@ -9041,12 +9041,12 @@ int set_dest_udp_list(int file_des) { "mac %s, mac2 %s]\n", entry, args[1], args[2], ip, ip2, mac, mac2)); - if (entry < 1 || entry > MAX_UDP_DESTINATION) { + if (entry < 1 || entry >= MAX_UDP_DESTINATION) { ret = FAIL; sprintf( mess, "Could not set udp destination. Invalid entry. Options: 1 - %d\n", - MAX_UDP_DESTINATION); + MAX_UDP_DESTINATION - 1); LOG(logERROR, (mess)); } #ifdef EIGERD @@ -9117,7 +9117,7 @@ int set_dest_udp_list(int file_des) { } // find number of destinations int numdest = 0; - for (int i = MAX_UDP_DESTINATION; i >= 0; --i) { + for (int i = MAX_UDP_DESTINATION - 1; i >= 0; --i) { if (udpDetails[i].dstip != 0) { numdest = i + 1; break;