diff options
author | Sven Nierlein <sven@nierlein.de> | 2021-02-04 10:21:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 10:21:26 (GMT) |
commit | 05d7f70d4553e19ea5eb27ec5c97098f014550df (patch) | |
tree | d3411ea84dc31105dbfb36d40d3fbf36a458fef0 | |
parent | 180e069169840c11196e9e2028c44493525f1918 (diff) | |
parent | ad99755033f33a301abc1815d746644067bc297a (diff) | |
download | monitoring-plugins-05d7f70d4553e19ea5eb27ec5c97098f014550df.tar.gz |
Merge pull request #1649 from DerDakon/split-addr
check_dns: split multiple IP addresses passed in one -a argument
-rw-r--r-- | plugins/check_dns.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c index b90f50e..0f2e654 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c | |||
@@ -473,9 +473,23 @@ process_arguments (int argc, char **argv) | |||
473 | case 'a': /* expected address */ | 473 | case 'a': /* expected address */ |
474 | if (strlen (optarg) >= ADDRESS_LENGTH) | 474 | if (strlen (optarg) >= ADDRESS_LENGTH) |
475 | die (STATE_UNKNOWN, _("Input buffer overflow\n")); | 475 | die (STATE_UNKNOWN, _("Input buffer overflow\n")); |
476 | expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**)); | 476 | if (strchr(optarg, ',') != NULL) { |
477 | expected_address[expected_address_cnt] = strdup(optarg); | 477 | char *comma = strchr(optarg, ','); |
478 | expected_address_cnt++; | 478 | while (comma != NULL) { |
479 | expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**)); | ||
480 | expected_address[expected_address_cnt] = strndup(optarg, comma - optarg); | ||
481 | expected_address_cnt++; | ||
482 | optarg = comma + 1; | ||
483 | comma = strchr(optarg, ','); | ||
484 | } | ||
485 | expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**)); | ||
486 | expected_address[expected_address_cnt] = strdup(optarg); | ||
487 | expected_address_cnt++; | ||
488 | } else { | ||
489 | expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**)); | ||
490 | expected_address[expected_address_cnt] = strdup(optarg); | ||
491 | expected_address_cnt++; | ||
492 | } | ||
479 | break; | 493 | break; |
480 | case 'A': /* expect authority */ | 494 | case 'A': /* expect authority */ |
481 | expect_authority = TRUE; | 495 | expect_authority = TRUE; |