aboutsummaryrefslogtreecommitdiff
path: root/plugins/check_by_ssh.c
diff options
context:
space:
mode:
authorGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-01-16 05:17:10 +0000
committerGravatar Karl DeBisschop <kdebisschop@users.sourceforge.net> 2003-01-16 05:17:10 +0000
commitb6f64e12900d1dc308a3325b4c5d80e76eade984 (patch)
treeca1e27a07627109b8a3021b4d682c6dc05826008 /plugins/check_by_ssh.c
parent7f7188e8de0a21d7846d0b0abcaa9fd38208ffbc (diff)
downloadmonitoring-plugins-b6f64e12900d1dc308a3325b4c5d80e76eade984.tar.gz
avoid segfault when host is not given
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@240 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_by_ssh.c')
-rw-r--r--plugins/check_by_ssh.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 5c505309..34e67274 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -283,14 +283,19 @@ process_arguments (int argc, char **argv)
c = optind;
if (hostname == NULL) {
- if (!is_host (argv[c]))
+ if (c <= argc) {
+ terminate (STATE_UNKNOWN, "%s: You must provide a host name\n", progname);
+ } else if (!is_host (argv[c]))
terminate (STATE_UNKNOWN, "%s: Invalid host name %s\n", progname, argv[c]);
hostname = argv[c++];
}
if (strlen(remotecmd) == 0) {
for (; c < argc; c++)
- asprintf (&remotecmd, "%s %s", remotecmd, argv[c]);
+ if (strlen(remotecmd) > 0)
+ asprintf (&remotecmd, "%s %s", remotecmd, argv[c]);
+ else
+ asprintf (&remotecmd, "%s", argv[c]);
}
if (commands > 1)