[Nagiosplug-checkins] CVS: nagiosplug/plugins check_ssh.c,1.5,1.6

Jeremy T. Bouse undrgrid at users.sourceforge.net
Mon Feb 10 10:37:05 CET 2003


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

Modified Files:
	check_ssh.c 
Log Message:
Added argc checks before attempting to access argv[]

Corrected return codes and output



Index: check_ssh.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_ssh.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** check_ssh.c	10 Feb 2003 14:18:00 -0000	1.5
--- check_ssh.c	10 Feb 2003 18:36:46 -0000	1.6
***************
*** 40,43 ****
--- 40,44 ----
  main (int argc, char **argv)
  {
+ 	int result;
  
  	if (process_arguments (argc, argv) == ERROR)
***************
*** 49,57 ****
  
  	/* ssh_connect exits if error is found */
! 	ssh_connect (server_name, port);
  
  	alarm (0);
  
! 	return (STATE_OK);
  }
  
--- 50,58 ----
  
  	/* ssh_connect exits if error is found */
! 	result = ssh_connect (server_name, port);
  
  	alarm (0);
  
! 	return (result);
  }
  
***************
*** 127,131 ****
  
  	c = optind;
! 	if (server_name == NULL && argv[c]) {
  		if (is_host (argv[c])) {
  			server_name = argv[c++];
--- 128,132 ----
  
  	c = optind;
! 	if (server_name == NULL && c < argc) {
  		if (is_host (argv[c])) {
  			server_name = argv[c++];
***************
*** 133,137 ****
  	}
  
! 	if (port == -1 && argv[c]) {
  		if (is_intpos (argv[c])) {
  			port = atoi (argv[c++]);
--- 134,138 ----
  	}
  
! 	if (port == -1 && c < argc) {
  		if (is_intpos (argv[c])) {
  			port = atoi (argv[c++]);
***************
*** 196,200 ****
  		ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;
  		printf
! 			("SSH ok - %s (protocol %s)\n",
  			 ssh_server, ssh_proto);
  		asprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, revision);
--- 197,201 ----
  		ssh_proto[strspn (ssh_proto, "0123456789. ")] = 0;
  		printf
! 			("SSH OK - %s (protocol %s)\n",
  			 ssh_server, ssh_proto);
  		asprintf (&buffer, "SSH-%s-check_ssh_%s\r\n", ssh_proto, revision);





More information about the Commits mailing list