aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sven Nierlein <sven@nierlein.de> 2021-02-04 11:21:26 +0100
committerGravatar GitHub <noreply@github.com> 2021-02-04 11:21:26 +0100
commit05d7f70d4553e19ea5eb27ec5c97098f014550df (patch)
treed3411ea84dc31105dbfb36d40d3fbf36a458fef0
parent180e069169840c11196e9e2028c44493525f1918 (diff)
parentad99755033f33a301abc1815d746644067bc297a (diff)
downloadmonitoring-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.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;