Skip to content

Commit e52ca1b

Browse files
committed
execve.2: execve also returns E2BIG if a string is too long
The execve syscall returns -E2BIG in 3 cases: - The total length of the command line arguments and environment is too large. - An argument or environment string (including the NUL byte) is longer than MAX_ARG_STRLEN. - The full path to the executable (including the NUL byte) exceeds MAX_ARG_STRLEN. Spell out all 3 cases in the -E2BIG section. Discovered by moving a too large commandline parameter to an environment variable, and finding that things still did not work. Examined the code in fs/exec.c to get the details. This simple shell script starts failing at 2^17 on a system with 4kB page size: ./exec2big.sh: line 10: /bin/true: Argument list too long fork failed at loop 17 STRING="a" for loop in `seq 20`; do STRING="$STRING$STRING" export STRING if /bin/true ; then : # still under the limit else echo "fork failed at loop $loop" fi done Signed-off-by: Rik van Riel <riel@surriel.com> Suggested-by: Matthew House <mattlloydhouse@gmail.com>
1 parent ae6b221 commit e52ca1b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

man2/execve.2

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,12 @@ The total number of bytes in the environment
449449
.RI ( envp )
450450
and argument list
451451
.RI ( argv )
452-
is too large.
452+
is too large,
453+
an argument or environment string is too long,
454+
or the full
455+
.I pathname
456+
of the executable is too long.
457+
The terminating NUL is counted as part of the string length.
453458
.TP
454459
.B EACCES
455460
Search permission is denied on a component of the path prefix of

0 commit comments

Comments
 (0)