summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins-root/check_icmp.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index f3c83ee0..8f5c1fe4 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -1926,18 +1926,21 @@ static get_threshold_wrapper get_threshold(char *str, check_icmp_threshold thres
1926 } 1926 }
1927 1927
1928 /* pointer magic slims code by 10 lines. i is bof-stop on stupid libc's */ 1928 /* pointer magic slims code by 10 lines. i is bof-stop on stupid libc's */
1929 bool is_at_last_char = false; 1929 size_t len = strlen(str);
1930 char *tmp = &str[strlen(str) - 1]; 1930 if (len >= 2) {
1931 while (tmp != &str[1]) { 1931 bool is_at_last_char = false;
1932 if (*tmp == '%') { 1932 char *tmp = &str[len - 1];
1933 *tmp = '\0'; 1933 while (tmp != &str[1]) {
1934 } else if (*tmp == ',' && is_at_last_char) { 1934 if (*tmp == '%') {
1935 *tmp = '\0'; /* reset it so get_timevar(str) works nicely later */ 1935 *tmp = '\0';
1936 result.threshold.pl = (unsigned char)strtoul(tmp + 1, NULL, 0); 1936 } else if (*tmp == ',' && is_at_last_char) {
1937 break; 1937 *tmp = '\0'; /* reset it so get_timevar(str) works nicely later */
1938 result.threshold.pl = (unsigned char)strtoul(tmp + 1, NULL, 0);
1939 break;
1940 }
1941 is_at_last_char = true;
1942 tmp--;
1938 } 1943 }
1939 is_at_last_char = true;
1940 tmp--;
1941 } 1944 }
1942 1945
1943 get_timevar_wrapper parsed_time = get_timevar(str); 1946 get_timevar_wrapper parsed_time = get_timevar(str);