diff options
-rw-r--r-- | plugins/check_dns.c | 1 | ||||
-rw-r--r-- | plugins/check_ntp_peer.c | 13 | ||||
-rw-r--r-- | plugins/utils.c | 15 |
3 files changed, 23 insertions, 6 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 5e20214..468bc95 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c | |||
@@ -87,7 +87,6 @@ main (int argc, char **argv) | |||
87 | struct timeval tv; | 87 | struct timeval tv; |
88 | bool parse_address = false; /* This flag scans for Address: but only after Name: */ | 88 | bool parse_address = false; /* This flag scans for Address: but only after Name: */ |
89 | output chld_out, chld_err; | 89 | output chld_out, chld_err; |
90 | size_t i; | ||
91 | bool is_nxdomain = false; | 90 | bool is_nxdomain = false; |
92 | 91 | ||
93 | setlocale (LC_ALL, ""); | 92 | setlocale (LC_ALL, ""); |
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c index 4fb9018..464a9e1 100644 --- a/plugins/check_ntp_peer.c +++ b/plugins/check_ntp_peer.c | |||
@@ -558,7 +558,6 @@ char *perfd_truechimers (int num_truechimers) | |||
558 | 558 | ||
559 | int main(int argc, char *argv[]){ | 559 | int main(int argc, char *argv[]){ |
560 | int result, offset_result, stratum, num_truechimers; | 560 | int result, offset_result, stratum, num_truechimers; |
561 | int oresult, jresult, sresult, tresult = STATE_UNKNOWN; | ||
562 | double offset=0, jitter=0; | 561 | double offset=0, jitter=0; |
563 | char *result_line, *perfdata_line; | 562 | char *result_line, *perfdata_line; |
564 | 563 | ||
@@ -595,18 +594,28 @@ int main(int argc, char *argv[]){ | |||
595 | result = STATE_UNKNOWN; | 594 | result = STATE_UNKNOWN; |
596 | result = max_state_alt(result, get_status(fabs(offset), offset_thresholds)); | 595 | result = max_state_alt(result, get_status(fabs(offset), offset_thresholds)); |
597 | } | 596 | } |
598 | oresult = result; | 597 | |
598 | int oresult = result; | ||
599 | |||
600 | |||
601 | int tresult = STATE_UNKNOWN; | ||
599 | 602 | ||
600 | if(do_truechimers) { | 603 | if(do_truechimers) { |
601 | tresult = get_status(num_truechimers, truechimer_thresholds); | 604 | tresult = get_status(num_truechimers, truechimer_thresholds); |
602 | result = max_state_alt(result, tresult); | 605 | result = max_state_alt(result, tresult); |
603 | } | 606 | } |
604 | 607 | ||
608 | |||
609 | int sresult = STATE_UNKNOWN; | ||
610 | |||
605 | if(do_stratum) { | 611 | if(do_stratum) { |
606 | sresult = get_status(stratum, stratum_thresholds); | 612 | sresult = get_status(stratum, stratum_thresholds); |
607 | result = max_state_alt(result, sresult); | 613 | result = max_state_alt(result, sresult); |
608 | } | 614 | } |
609 | 615 | ||
616 | |||
617 | int jresult = STATE_UNKNOWN; | ||
618 | |||
610 | if(do_jitter) { | 619 | if(do_jitter) { |
611 | jresult = get_status(jitter, jitter_thresholds); | 620 | jresult = get_status(jitter, jitter_thresholds); |
612 | result = max_state_alt(result, jresult); | 621 | result = max_state_alt(result, jresult); |
diff --git a/plugins/utils.c b/plugins/utils.c index e871c5f..aff1790 100644 --- a/plugins/utils.c +++ b/plugins/utils.c | |||
@@ -258,16 +258,25 @@ bool is_int64(char *number, int64_t *target) { | |||
258 | */ | 258 | */ |
259 | bool is_uint64(char *number, uint64_t *target) { | 259 | bool is_uint64(char *number, uint64_t *target) { |
260 | errno = 0; | 260 | errno = 0; |
261 | uint64_t tmp = strtoll(number, NULL, 10); | 261 | char *endptr = { 0 }; |
262 | unsigned long long tmp = strtoull(number, &endptr, 10); | ||
263 | |||
262 | if (errno != 0) { | 264 | if (errno != 0) { |
263 | return false; | 265 | return false; |
264 | } | 266 | } |
265 | if (tmp < 0 || tmp > UINT64_MAX) { | 267 | |
268 | if (*endptr != '\0') { | ||
266 | return false; | 269 | return false; |
267 | } | 270 | } |
271 | |||
272 | if (tmp > UINT64_MAX) { | ||
273 | return false; | ||
274 | } | ||
275 | |||
268 | if (target != NULL) { | 276 | if (target != NULL) { |
269 | *target = tmp; | 277 | *target = (uint64_t)tmp; |
270 | } | 278 | } |
279 | |||
271 | return true; | 280 | return true; |
272 | } | 281 | } |
273 | 282 | ||