From a25b98d939f46206542c4c9c383c61d218151e2f Mon Sep 17 00:00:00 2001 From: Matthias Eble Date: Mon, 11 Jun 2007 20:54:07 +0000 Subject: 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 --- THANKS.in | 1 + plugins/popen.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/THANKS.in b/THANKS.in index baed6965..f666248e 100644 --- a/THANKS.in +++ b/THANKS.in @@ -219,3 +219,4 @@ Denis Knauf Matthias Flacke Emil Michles Ask Bjoern Hansen +Daniel Bimschas 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; -- cgit v1.2.3-74-g34f1