Properly handle command line truncation
Unlikely to happen since ARG_MAX is 256K, but...
This commit is contained in:
parent
84b2c1858a
commit
41f9a167e3
10
service.c
10
service.c
@ -212,15 +212,21 @@ void serviceStart(struct Service *service) {
|
|||||||
);
|
);
|
||||||
assert(n > 0);
|
assert(n > 0);
|
||||||
len += n;
|
len += n;
|
||||||
|
if (len >= sizeof(command)) errx(ExitNoExec, "command truncated");
|
||||||
}
|
}
|
||||||
snprintf(&command[len], sizeof(command) - len, "exec %s", service->command);
|
int n = snprintf(
|
||||||
|
&command[len], sizeof(command) - len, "exec %s", service->command
|
||||||
|
);
|
||||||
|
assert(n > 0);
|
||||||
|
len += n;
|
||||||
|
if (len >= sizeof(command)) errx(ExitNoExec, "command truncated");
|
||||||
|
|
||||||
execle(
|
execle(
|
||||||
_PATH_BSHELL,
|
_PATH_BSHELL,
|
||||||
_PATH_BSHELL, "-c", command, service->name, NULL,
|
_PATH_BSHELL, "-c", command, service->name, NULL,
|
||||||
serviceEnviron
|
serviceEnviron
|
||||||
);
|
);
|
||||||
err(ExitNotFound, "%s", _PATH_BSHELL);
|
err(ExitNoExec, "%s", _PATH_BSHELL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serviceSignal(struct Service *service, int signal) {
|
void serviceSignal(struct Service *service, int signal) {
|
||||||
|
Loading…
Reference in New Issue
Block a user