From a88f40d7e39a46dc10c4aaf42f4c1b2301caec33 Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Sat, 31 May 2003 14:04:05 +0000 Subject: trap null or empty returns from nslookup git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/branches/release-1.3.0@524 f882894a-f735-0410-b71e-b25c423dba1c diff --git a/plugins/check_dns.c b/plugins/check_dns.c index 19649f5..df8359c 100644 --- a/plugins/check_dns.c +++ b/plugins/check_dns.c @@ -136,12 +136,14 @@ 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", %s); result = STATE_OK; } else { - output = strscpy (output, "Unknown error (plugin)"); + output = strdup ("Unknown error (plugin)"); result = STATE_WARNING; } @@ -176,9 +178,9 @@ main (int argc, char **argv) /* 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); + } (void) time (&end_time); -- cgit v0.10-9-g596f