execvpe limits PATH environment variable to PATH_MAX
DJ Delorie
dj@redhat.com
Tue Mar 31 03:56:16 GMT 2020
Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> writes:
> And I don't think it would be a good practice to use a different
> semantic for execvpe, i.e, allow arbitrary size paths.
Does the standard allow arbitrary sized environment strings? If so, we
should not limit our implementation. (it doesn't but it doesn't limit
$PATH to PATH_MAX either)
Also, PATH_MAX has nothing to do with environment strings - it's the
maximum size of a filesystem pathname. Let's not abuse it.
If anything, we should use ARG_MAX [1][2]. I will note that PATH_MAX is
4,096 on my system, but ARG_MAX is 131,072. That might break alloca.
[E2BIG]
The number of bytes used by the new process image's argument list and
environment list is greater than the system-imposed limit of {ARG_MAX}
bytes.
The only mention of PATH_MAX in exec*() is
[ENAMETOOLONG]
The length of the path argument or the length of the pathname
constructed from the file argument exceeds {PATH_MAX}, or pathname
resolution of a symbolic link produced an intermediate result with a
length that exceeds {PATH_MAX}.
... which only refers to the pathname to the image to be exec'd, not the
arguments or environment.
[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
[2] https://pubs.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html
{ARG_MAX}
Maximum length of argument to the exec functions including environment
data. Minimum Acceptable Value: {_POSIX_ARG_MAX}
More information about the Libc-alpha
mailing list