X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fpopen.c;h=45d2a3dc937e19345e4da5605465660f683c6673;hb=15255ec599506db603b5089357fb137536497537;hp=80a7119b983cc711452a3524f77417e1434c8b58;hpb=f9394308c9c372bcf419a311c61ba420247ae613;p=nagiosplug.git diff --git a/plugins/popen.c b/plugins/popen.c index 80a7119..45d2a3d 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;