[PATCH] posix: execvpe: skip $PATH components that are too long
Paul Eggert
eggert@cs.ucla.edu
Sat Nov 8 18:38:53 GMT 2025
On 2025-11-08 09:09, Bruno Haible wrote:
> The kernel will return ENAMETOOLONG for attempts
> to access D1/F. However, this does *not* mean that F does
> not exist in F1. Therefore, it does *not* mean that D2/F
> should be picked and executed.
I'm not quite seeing that. POSIX says that the search continues "until
an executable file with appropriate execution permissions is found"[1]
so it boils down to what is meant by "found". My interpretation is that
ENAMETOOLONG means such a file is not "found" there, so the search
should continue.
For what it's worth, FreeBSD execvpe[2] treats ENAMETOOLONG the same way
as the proposed patch.
FreeBSD puts ELOOP into the same category as ENOENT/ENAMETOOLONG/etc.,
and it would make sense to add ELOOP while we're in the neighborhood.
That is, a symlink loop should not prevent execvpe from looking later in
PATH, as such a loop means the file was not "found" at the current spot.
[1]:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/V1_chap08.html#tag_08_03
[2]:
https://github.com/freebsd/freebsd-src/blob/main/lib/libc/gen/exec.c#L159
More information about the Libc-alpha
mailing list