[PATCH] posix: execvpe: skip $PATH components that are too long
Paul Eggert
eggert@cs.ucla.edu
Tue Nov 18 07:40:51 GMT 2025
On 2025-11-17 21:58, Collin Funk wrote:
> The POSIX page for the execs function states [1]:
>
> The exec functions, except for fexecve(), shall fail if:
>
> [ENAMETOOLONG]
> The length of a component of a pathname is longer than
> {NAME_MAX}.
>
> So shouldn't the current behavior be correct?
No, because that list also contains entries like this:
[ENOENT]
A component of path or file does not name an existing file or
path or file is an empty string.
Obviously execlp and execvp shouldn't fail merely because their first
attempt fails with ENOENT: they're supposed to keep going and look later
in the PATH. The situation for ENAMETOOLONG is the same.
At least, that's the intent (though perhaps the POSIX wording could be
improved to make this clearer).
More information about the Libc-alpha
mailing list