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:
@@ -25,7 +25,7 @@
|
|||||||
.nr BA @BAMAN@
|
.nr BA @BAMAN@
|
||||||
.nr LC @LCMAN@
|
.nr LC @LCMAN@
|
||||||
.nr PS @PSMAN@
|
.nr PS @PSMAN@
|
||||||
.TH "SUDO" "@mansectsu@" "March 31, 2020" "Sudo @PACKAGE_VERSION@" "System Manager's Manual"
|
.TH "SUDO" "@mansectsu@" "April 2, 2020" "Sudo @PACKAGE_VERSION@" "System Manager's Manual"
|
||||||
.nh
|
.nh
|
||||||
.if n .ad l
|
.if n .ad l
|
||||||
.SH "NAME"
|
.SH "NAME"
|
||||||
@@ -1140,7 +1140,9 @@ if no terminal is available or if the
|
|||||||
option is specified.
|
option is specified.
|
||||||
.TP 17n
|
.TP 17n
|
||||||
\fRSUDO_COMMAND\fR
|
\fRSUDO_COMMAND\fR
|
||||||
Set to the command run by sudo.
|
Set to the command run by sudo, including command line arguments.
|
||||||
|
The command line arguments are truncated at 4096 characters to
|
||||||
|
prevent a potential execution error.
|
||||||
.TP 17n
|
.TP 17n
|
||||||
\fRSUDO_EDITOR\fR
|
\fRSUDO_EDITOR\fR
|
||||||
Default editor to use in
|
Default editor to use in
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
.nr BA @BAMAN@
|
.nr BA @BAMAN@
|
||||||
.nr LC @LCMAN@
|
.nr LC @LCMAN@
|
||||||
.nr PS @PSMAN@
|
.nr PS @PSMAN@
|
||||||
.Dd March 31, 2020
|
.Dd April 2, 2020
|
||||||
.Dt SUDO @mansectsu@
|
.Dt SUDO @mansectsu@
|
||||||
.Os Sudo @PACKAGE_VERSION@
|
.Os Sudo @PACKAGE_VERSION@
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@@ -1071,7 +1071,9 @@ if no terminal is available or if the
|
|||||||
.Fl A
|
.Fl A
|
||||||
option is specified.
|
option is specified.
|
||||||
.It Ev SUDO_COMMAND
|
.It Ev SUDO_COMMAND
|
||||||
Set to the command run by sudo.
|
Set to the command run by sudo, including command line arguments.
|
||||||
|
The command line arguments are truncated at 4096 characters to
|
||||||
|
prevent a potential execution error.
|
||||||
.It Ev SUDO_EDITOR
|
.It Ev SUDO_EDITOR
|
||||||
Default editor to use in
|
Default editor to use in
|
||||||
.Fl e
|
.Fl e
|
||||||
|
@@ -1109,7 +1109,12 @@ rebuild_env(void)
|
|||||||
|
|
||||||
/* Add the SUDO_COMMAND envariable (cmnd + args). */
|
/* Add the SUDO_COMMAND envariable (cmnd + args). */
|
||||||
if (user_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;
|
goto bad;
|
||||||
if (sudo_putenv(cp, true, true) == -1) {
|
if (sudo_putenv(cp, true, true) == -1) {
|
||||||
free(cp);
|
free(cp);
|
||||||
|
Reference in New Issue
Block a user