summaryrefslogtreecommitdiffstats
path: root/plugins/popen.c
diff options
context:
space:
mode:
authorMatthias Eble <psychotrahe@users.sourceforge.net>2007-06-11 20:54:07 +0000
committerMatthias Eble <psychotrahe@users.sourceforge.net>2007-06-11 20:54:07 +0000
commita25b98d939f46206542c4c9c383c61d218151e2f (patch)
tree493aab9e7f0520d77ca8cffde18e52a07580403d /plugins/popen.c
parentb5886d1c5d07a51ad1ab4b866c4dcc8a60446001 (diff)
downloadmonitoring-plugins-a25b98d939f46206542c4c9c383c61d218151e2f.tar.gz
Fixed problem with popen.c not parsing --longopt='foo bar' correctly (Daniel Bimschas #1291987)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1736 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/popen.c')
-rw-r--r--plugins/popen.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/popen.c b/plugins/popen.c
index 80a7119b..a7e6f9b2 100644
--- a/plugins/popen.c
+++ b/plugins/popen.c
@@ -104,7 +104,7 @@ spopen (const char *cmdstring)
104 char *env[2]; 104 char *env[2];
105 char *cmd = NULL; 105 char *cmd = NULL;
106 char **argv = NULL; 106 char **argv = NULL;
107 char *str; 107 char *str, *tmp;
108 int argc; 108 int argc;
109 109
110 int i = 0, pfd[2], pfderr[2]; 110 int i = 0, pfd[2], pfderr[2];
@@ -166,7 +166,15 @@ spopen (const char *cmdstring)
166 cmd = 1 + strstr (str, "'"); 166 cmd = 1 + strstr (str, "'");
167 str[strcspn (str, "'")] = 0; 167 str[strcspn (str, "'")] = 0;
168 } 168 }
169 else { 169 else if (strcspn(str,"'") < strcspn (str, " \t\r\n")) {
170 /* handle --option='foo bar' strings */
171 tmp = str + strcspn(str, "'") + 1;
172 if (!strstr (tmp, "'"))
173 return NULL; /* balanced? */
174 tmp += strcspn(tmp,"'") + 1;
175 *tmp = 0;
176 cmd = tmp + 1;
177 } else {
170 if (strpbrk (str, " \t\r\n")) { 178 if (strpbrk (str, " \t\r\n")) {
171 cmd = 1 + strpbrk (str, " \t\r\n"); 179 cmd = 1 + strpbrk (str, " \t\r\n");
172 str[strcspn (str, " \t\r\n")] = 0; 180 str[strcspn (str, " \t\r\n")] = 0;
@@ -180,6 +188,7 @@ spopen (const char *cmdstring)
180 cmd = NULL; 188 cmd = NULL;
181 189
182 argv[i++] = str; 190 argv[i++] = str;
191 printf("arg no.%i: %s\n",i,str);
183 192
184 } 193 }
185 argv[i] = NULL; 194 argv[i] = NULL;