summaryrefslogtreecommitdiffstats
path: root/plugins/check_dns.c
diff options
context:
space:
mode:
authorKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-05-31 14:39:21 (GMT)
committerKarl DeBisschop <kdebisschop@users.sourceforge.net>2003-05-31 14:39:21 (GMT)
commitcc032457cfe982c9b608150a87a54e443903ba16 (patch)
treeaef0c1cb9aafbf5a5b3046a3bdebb2bd01c0ed2f /plugins/check_dns.c
parent817eed9c0f8814b2b364eb945cbab665389b1d05 (diff)
downloadmonitoring-plugins-cc032457cfe982c9b608150a87a54e443903ba16.tar.gz
first revised patch failed to trap the "break" in while()
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@526 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_dns.c')
-rw-r--r--plugins/check_dns.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index 2765f64..f1071d8 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -139,12 +139,16 @@ main (int argc, char **argv)
139 /* Strip leading spaces */ 139 /* Strip leading spaces */
140 for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++) 140 for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
141 /* NOOP */; 141 /* NOOP */;
142 address = strscpy (address, temp_buffer); 142 address = strdup (temp_buffer);
143 strip (address); 143 strip (address);
144 if (address==NULL || strlen(address)==0)
145 terminate (STATE_CRITICAL,
146 "DNS CRITICAL - '%s' returned empty host name string\n",
147 NSLOOKUP_COMMAND);
144 result = STATE_OK; 148 result = STATE_OK;
145 } 149 }
146 else { 150 else {
147 output = strscpy (output, "Unknown error (plugin)"); 151 output = strdup ("Unknown error (plugin)");
148 result = STATE_WARNING; 152 result = STATE_WARNING;
149 } 153 }
150 154
@@ -179,11 +183,18 @@ main (int argc, char **argv)
179 output = strscpy (output, "nslookup returned error status"); 183 output = strscpy (output, "nslookup returned error status");
180 } 184 }
181 185
186 /* If we got here, we should have an address string,
187 and we can segfault if we do not */
188 if (address==NULL || strlen(address)==0)
189 terminate (STATE_CRITICAL,
190 "DNS CRITICAL - '%s' output parsing exited with no address\n",
191 NSLOOKUP_COMMAND);
192
182 /* compare to expected address */ 193 /* compare to expected address */
183 if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) { 194 if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) {
184 result = STATE_CRITICAL; 195 result = STATE_CRITICAL;
185 asprintf(&output, "expected %s but got %s", expected_address, address); 196 asprintf(&output, "expected %s but got %s", expected_address, address);
186 } 197 }
187 198
188 elapsed_time = delta_time (tv); 199 elapsed_time = delta_time (tv);
189 200