aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_dns.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-05-31 14:39:21 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-05-31 14:39:21 +0000
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 2765f643..f1071d8e 100644
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
@@ -139,12 +139,16 @@ main (int argc, char **argv)
/* Strip leading spaces */
for (; *temp_buffer != '\0' && *temp_buffer == ' '; temp_buffer++)
/* NOOP */;
- address = strscpy (address, temp_buffer);
+ address = strdup (temp_buffer);
strip (address);
+ if (address==NULL || strlen(address)==0)
+ terminate (STATE_CRITICAL,
+ "DNS CRITICAL - '%s' returned empty host name string\n",
+ NSLOOKUP_COMMAND);
result = STATE_OK;
}
else {
- output = strscpy (output, "Unknown error (plugin)");
+ output = strdup ("Unknown error (plugin)");
result = STATE_WARNING;
}
@@ -179,11 +183,18 @@ main (int argc, char **argv)
output = strscpy (output, "nslookup returned error status");
}
+ /* If we got here, we should have an address string,
+ and we can segfault if we do not */
+ if (address==NULL || strlen(address)==0)
+ terminate (STATE_CRITICAL,
+ "DNS CRITICAL - '%s' output parsing exited with no address\n",
+ NSLOOKUP_COMMAND);
+
/* compare to expected address */
if (result == STATE_OK && match_expected_address && strcmp(address, expected_address)) {
- result = STATE_CRITICAL;
- asprintf(&output, "expected %s but got %s", expected_address, address);
- }
+ result = STATE_CRITICAL;
+ asprintf(&output, "expected %s but got %s", expected_address, address);
+ }
elapsed_time = delta_time (tv);