[Nagiosplug-checkins] nagiosplug/plugins check_smtp.c,1.59,1.60

Matthias Eble psychotrahe at users.sourceforge.net
Sat Jul 14 21:36:50 CEST 2007


Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12224/plugins

Modified Files:
	check_smtp.c 
Log Message:
Fixed segfault in argument processing. Thanks to Christoph Schell (#1742066)


Index: check_smtp.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/check_smtp.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- check_smtp.c	6 Mar 2007 22:29:27 -0000	1.59
+++ check_smtp.c	14 Jul 2007 19:36:48 -0000	1.60
@@ -582,22 +582,26 @@
 			break;
 		case 'C':									/* commands  */
 			if (ncommands >= command_size) {
-				commands = realloc (commands, command_size+8);
+				command_size+=8;
+				commands = realloc (commands, sizeof(char *) * command_size);
 				if (commands == NULL)
 					die (STATE_UNKNOWN,
 					     _("Could not realloc() units [%d]\n"), ncommands);
 			}
-			commands[ncommands] = optarg;
+			commands[ncommands] = (char *) malloc (sizeof(char) * 255);
+			strncpy (commands[ncommands], optarg, 255);
 			ncommands++;
 			break;
 		case 'R':									/* server responses */
 			if (nresponses >= response_size) {
-				responses = realloc (responses, response_size+8);
+				response_size += 8;
+				responses = realloc (responses, sizeof(char *) * response_size);
 				if (responses == NULL)
 					die (STATE_UNKNOWN,
 					     _("Could not realloc() units [%d]\n"), nresponses);
 			}
-			responses[nresponses] = optarg;
+			responses[nresponses] = (char *) malloc (sizeof(char) * 255);
+			strncpy (responses[nresponses], optarg, 255);
 			nresponses++;
 			break;
 		case 'c':									/* critical time threshold */





More information about the Commits mailing list