mirror of
https://github.com/troglobit/finit.git
synced 2026-10-26 12:14:37 +00:00
Work around forbidden chars in wordexp(): | < > & ;
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
001e859a97
commit
41319a8cf8
1 file changed
+17
-2
+17
-2
@@ -493,10 +493,25 @@ static int service_start(svc_t *svc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_NUM_SVC_ARGS; i++) {
|
for (i = 0; i < MAX_NUM_SVC_ARGS; i++) {
|
||||||
if (strlen(svc->args[i]) == 0)
|
char *arg = svc->args[i];
|
||||||
|
size_t len = strlen(arg);
|
||||||
|
char str[len + 2] = {0};
|
||||||
|
char ch = *arg;
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ((rc = wordexp(svc->args[i], &we, WRDE_APPEND)))
|
/*
|
||||||
|
* Escape forbidden characters in wordexp()
|
||||||
|
* but allowed in Finit run/task stanzas,
|
||||||
|
*
|
||||||
|
* XXX: escapes only leading characters ...
|
||||||
|
*/
|
||||||
|
if (strchr("|<>&:", ch))
|
||||||
|
str[0] = '\\';
|
||||||
|
strlcat(str, arg, sizeof(str));
|
||||||
|
|
||||||
|
if ((rc = wordexp(str, &we, WRDE_APPEND)))
|
||||||
goto nomem;
|
goto nomem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user