nagiosplug/plugins check_smtp.c,1.59,1.60

Matthias Eble <[email protected]>
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
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 */


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.