Code

Fixed problem with popen.c not parsing --longopt='foo bar' correctly (Daniel Bimschas...
authorMatthias Eble <psychotrahe@users.sourceforge.net>
Mon, 11 Jun 2007 20:54:07 +0000 (20:54 +0000)
committerMatthias Eble <psychotrahe@users.sourceforge.net>
Mon, 11 Jun 2007 20:54:07 +0000 (20:54 +0000)
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1736 f882894a-f735-0410-b71e-b25c423dba1c

THANKS.in
plugins/popen.c

index baed6965ab21e4379231e2e2c4673dcb5c6723b0..f666248ebc4a9b5846eb1b817cfe0fd154dd5f8b 100644 (file)
--- a/THANKS.in
+++ b/THANKS.in
@@ -219,3 +219,4 @@ Denis Knauf
 Matthias Flacke
 Emil Michles
 Ask Bjoern Hansen
+Daniel Bimschas
index 80a7119b983cc711452a3524f77417e1434c8b58..a7e6f9b2f238c202297c95256f5287f530e47059 100644 (file)
@@ -104,7 +104,7 @@ spopen (const char *cmdstring)
        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 @@ spopen (const char *cmdstring)
                        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 @@ spopen (const char *cmdstring)
                        cmd = NULL;
 
                argv[i++] = str;
+               printf("arg no.%i: %s\n",i,str);
 
        }
        argv[i] = NULL;