diff options
author | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-06-11 20:54:07 +0000 |
---|---|---|
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-06-11 20:54:07 +0000 |
commit | a25b98d939f46206542c4c9c383c61d218151e2f (patch) | |
tree | 493aab9e7f0520d77ca8cffde18e52a07580403d /plugins/popen.c | |
parent | b5886d1c5d07a51ad1ab4b866c4dcc8a60446001 (diff) | |
download | monitoring-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.c | 13 |
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) 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; |