[Nagiosplug-checkins] CVS: nagiosplug/plugins check_by_ssh.c,1.7,1.8

Karl DeBisschop kdebisschop at users.sourceforge.net
Wed Jan 15 21:18:02 CET 2003


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1:/tmp/cvs-serv773/plugins

Modified Files:
	check_by_ssh.c 
Log Message:
avoid segfault when host is not given

Index: check_by_ssh.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_by_ssh.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** check_by_ssh.c	13 Jan 2003 12:15:15 -0000	1.7
--- check_by_ssh.c	16 Jan 2003 05:17:10 -0000	1.8
***************
*** 284,288 ****
  	c = optind;
  	if (hostname == NULL) {
! 		if (!is_host (argv[c]))
  			terminate (STATE_UNKNOWN, "%s: Invalid host name %s\n", progname, argv[c]);
  		hostname = argv[c++];
--- 284,290 ----
  	c = optind;
  	if (hostname == NULL) {
! 		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++];
***************
*** 291,295 ****
  	if (strlen(remotecmd) == 0) {
  		for (; c < argc; c++)
! 			asprintf (&remotecmd, "%s %s", remotecmd, argv[c]);
  	}
  
--- 293,300 ----
  	if (strlen(remotecmd) == 0) {
  		for (; c < argc; c++)
! 			if (strlen(remotecmd) > 0)
! 				asprintf (&remotecmd, "%s %s", remotecmd, argv[c]);
! 			else
! 				asprintf (&remotecmd, "%s", argv[c]);
  	}
  





More information about the Commits mailing list