aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_dns.c
diff options
context:
space:
mode:
authorGravatar Rolf Eike Beer <eike@sf-mail.de> 2020-11-02 20:05:56 +0100
committerGravatar Rolf Eike Beer <eike@sf-mail.de> 2020-11-02 20:05:56 +0100
commitad99755033f33a301abc1815d746644067bc297a (patch)
tree1405d7d48df213aac85f6ba215feb7d5c05719d6 /plugins/check_dns.c
parent67877a296ef5a0f2f17efd8c2f069c3b4689ccd0 (diff)
downloadmonitoring-plugins-ad99755033f33a301abc1815d746644067bc297a.tar.gz
check_dns: split multiple IP addresses passed in one -a argument
Diffstat (limited to 'plugins/check_dns.c')
-rw-r--r--plugins/check_dns.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index b90f50e6..0f2e6541 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -473,9 +473,23 @@ process_arguments (int argc, char **argv)
case 'a': /* expected address */
if (strlen (optarg) >= ADDRESS_LENGTH)
die (STATE_UNKNOWN, _("Input buffer overflow\n"));
- expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
- expected_address[expected_address_cnt] = strdup(optarg);
- expected_address_cnt++;
+ if (strchr(optarg, ',') != NULL) {
+ char *comma = strchr(optarg, ',');
+ while (comma != NULL) {
+ expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
+ expected_address[expected_address_cnt] = strndup(optarg, comma - optarg);
+ expected_address_cnt++;
+ optarg = comma + 1;
+ comma = strchr(optarg, ',');
+ }
+ expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
+ expected_address[expected_address_cnt] = strdup(optarg);
+ expected_address_cnt++;
+ } else {
+ expected_address = (char **)realloc(expected_address, (expected_address_cnt+1) * sizeof(char**));
+ expected_address[expected_address_cnt] = strdup(optarg);
+ expected_address_cnt++;
+ }
break;
case 'A': /* expect authority */
expect_authority = TRUE;