summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_dns.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 8ae48cd..3565802 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -77,7 +77,7 @@ main (int argc, char **argv)
77{ 77{
78 char *command_line = NULL; 78 char *command_line = NULL;
79 char input_buffer[MAX_INPUT_BUFFER]; 79 char input_buffer[MAX_INPUT_BUFFER];
80 char *address = NULL; 80 char *address = NULL; /* comma seperated str with addrs/ptrs (sorted) */
81 char **addresses = NULL; 81 char **addresses = NULL;
82 int n_addresses = 0; 82 int n_addresses = 0;
83 char *msg = NULL; 83 char *msg = NULL;
@@ -122,12 +122,17 @@ main (int argc, char **argv)
122 122
123 /* scan stdout */ 123 /* scan stdout */
124 for(i = 0; i < chld_out.lines; i++) { 124 for(i = 0; i < chld_out.lines; i++) {
125 if (addresses == NULL)
126 addresses = malloc(sizeof(*addresses)*10);
127 else if (!(n_addresses % 10))
128 addresses = realloc(addresses,sizeof(*addresses) * (n_addresses + 10));
129
125 if (verbose) 130 if (verbose)
126 puts(chld_out.line[i]); 131 puts(chld_out.line[i]);
127 132
128 if (strstr (chld_out.line[i], ".in-addr.arpa")) { 133 if (strstr (chld_out.line[i], ".in-addr.arpa")) {
129 if ((temp_buffer = strstr (chld_out.line[i], "name = "))) 134 if ((temp_buffer = strstr (chld_out.line[i], "name = ")))
130 address = strdup (temp_buffer + 7); 135 addresses[n_addresses++] = strdup (temp_buffer + 7);
131 else { 136 else {
132 msg = (char *)_("Warning plugin error"); 137 msg = (char *)_("Warning plugin error");
133 result = STATE_WARNING; 138 result = STATE_WARNING;
@@ -153,10 +158,6 @@ main (int argc, char **argv)
153 NSLOOKUP_COMMAND); 158 NSLOOKUP_COMMAND);
154 } 159 }
155 160
156 if (addresses == NULL)
157 addresses = malloc(sizeof(*addresses)*10);
158 else if (!(n_addresses % 10))
159 addresses = realloc(addresses,sizeof(*addresses) * (n_addresses + 10));
160 addresses[n_addresses++] = strdup(temp_buffer); 161 addresses[n_addresses++] = strdup(temp_buffer);
161 } 162 }
162 else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) { 163 else if (strstr (chld_out.line[i], _("Non-authoritative answer:"))) {