summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-07 09:48:57 (GMT)
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-07 09:48:57 (GMT)
commit19dc0039365e5cae0ed866c10202c50338f70b0a (patch)
tree9df3a28d371ad76d160c557e6f8645e78a57ef48
parent9faa417aeb468be0ebb646ee3fc276014795e76f (diff)
downloadmonitoring-plugins-19dc0039365e5cae0ed866c10202c50338f70b0a.tar.gz
Do some actual error checking on the threshold parser
-rw-r--r--plugins-root/check_icmp.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index c71ea29..7140aa5 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -526,7 +526,8 @@ main(int argc, char **argv)
526 /* Reset argument scanning */ 526 /* Reset argument scanning */
527 optind = 1; 527 optind = 1;
528 528
529 unsigned long size; 529 unsigned long size;
530 bool err;
530 /* parse the arguments */ 531 /* parse the arguments */
531 for(i = 1; i < argc; i++) { 532 for(i = 1; i < argc; i++) {
532 while((arg = getopt(argc, argv, opts_str)) != EOF) { 533 while((arg = getopt(argc, argv, opts_str)) != EOF) {
@@ -591,23 +592,48 @@ main(int argc, char **argv)
591 exit (STATE_UNKNOWN); 592 exit (STATE_UNKNOWN);
592 break; 593 break;
593 case 'R': /* RTA mode */ 594 case 'R': /* RTA mode */
594 get_threshold2(optarg, strlen(optarg), &warn, &crit, const_rta_mode); 595 err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_rta_mode);
596
597 if (!err) {
598 crash("Failed to parse RTA threshold");
599 }
600
595 rta_mode=true; 601 rta_mode=true;
596 break; 602 break;
597 case 'P': /* packet loss mode */ 603 case 'P': /* packet loss mode */
598 get_threshold2(optarg, strlen(optarg), &warn, &crit, const_packet_loss_mode); 604 err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_packet_loss_mode);
605
606 if (!err) {
607 crash("Failed to parse packet loss threshold");
608 }
609
599 pl_mode=true; 610 pl_mode=true;
600 break; 611 break;
601 case 'J': /* jitter mode */ 612 case 'J': /* jitter mode */
602 get_threshold2(optarg, strlen(optarg), &warn, &crit, const_jitter_mode); 613 err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_jitter_mode);
614
615 if (!err) {
616 crash("Failed to parse jitter threshold");
617 }
618
603 jitter_mode=true; 619 jitter_mode=true;
604 break; 620 break;
605 case 'M': /* MOS mode */ 621 case 'M': /* MOS mode */
606 get_threshold2(optarg, strlen(optarg), &warn, &crit, const_mos_mode); 622 err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_mos_mode);
623
624 if (!err) {
625 crash("Failed to parse MOS threshold");
626 }
627
607 mos_mode=true; 628 mos_mode=true;
608 break; 629 break;
609 case 'S': /* score mode */ 630 case 'S': /* score mode */
610 get_threshold2(optarg, strlen(optarg), &warn, &crit, const_score_mode); 631 err = get_threshold2(optarg, strlen(optarg), &warn, &crit, const_score_mode);
632
633 if (!err) {
634 crash("Failed to parse score threshold");
635 }
636
611 score_mode=true; 637 score_mode=true;
612 break; 638 break;
613 case 'O': /* out of order mode */ 639 case 'O': /* out of order mode */