[Nagiosplug-checkins] nagiosplug/plugins popen.c,1.15,1.16

Matthias Eble psychotrahe at users.sourceforge.net
Mon Jun 11 22:54:10 CEST 2007


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

Modified Files:
	popen.c 
Log Message:
Fixed problem with popen.c not parsing --longopt='foo bar' correctly (Daniel Bimschas #1291987)


Index: popen.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/popen.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- popen.c	18 Jun 2006 19:36:48 -0000	1.15
+++ popen.c	11 Jun 2007 20:54:07 -0000	1.16
@@ -104,7 +104,7 @@
 	char *env[2];
 	char *cmd = NULL;
 	char **argv = NULL;
-	char *str;
+	char *str, *tmp;
 	int argc;
 
 	int i = 0, pfd[2], pfderr[2];
@@ -166,7 +166,15 @@
 			cmd = 1 + strstr (str, "'");
 			str[strcspn (str, "'")] = 0;
 		}
-		else {
+		else if (strcspn(str,"'") < strcspn (str, " \t\r\n")) {
+										/* handle --option='foo bar' strings */
+			tmp = str + strcspn(str, "'") + 1; 
+			if (!strstr (tmp, "'"))
+				return NULL;						/* balanced? */
+			tmp += strcspn(tmp,"'") + 1;
+			*tmp = 0;
+			cmd = tmp + 1;
+		} else {
 			if (strpbrk (str, " \t\r\n")) {
 				cmd = 1 + strpbrk (str, " \t\r\n");
 				str[strcspn (str, " \t\r\n")] = 0;
@@ -180,6 +188,7 @@
 			cmd = NULL;
 
 		argv[i++] = str;
+		printf("arg no.%i: %s\n",i,str);
 
 	}
 	argv[i] = NULL;





More information about the Commits mailing list