Truncate the command args at 4096 chars when formatting SUDO_COMMAND.
We have to limit the length of SUDO_COMMAND to avoid getting E2BIG from execve(2) for very long argument vectors. The command's environment also counts against the ARG_MAX limit. Debian bug #596631
This commit is contained in:
@@ -1109,7 +1109,12 @@ rebuild_env(void)
|
||||
|
||||
/* Add the SUDO_COMMAND envariable (cmnd + args). */
|
||||
if (user_args) {
|
||||
if (asprintf(&cp, "SUDO_COMMAND=%s %s", user_cmnd, user_args) == -1)
|
||||
/*
|
||||
* We limit user_args to 4096 bytes to avoid an execve() failure
|
||||
* for very long argument vectors. The command's environment also
|
||||
* counts against the ARG_MAX limit.
|
||||
*/
|
||||
if (asprintf(&cp, "SUDO_COMMAND=%s %.*s", user_cmnd, 4096, user_args) == -1)
|
||||
goto bad;
|
||||
if (sudo_putenv(cp, true, true) == -1) {
|
||||
free(cp);
|
||||
|
Reference in New Issue
Block a user