posix_spawn: use larger stack to cover worst-case in execvpe
authorWill Dietz <w@wdtz.org>
Thu, 14 Sep 2017 21:32:59 +0000 (16:32 -0500)
committerRich Felker <dalias@aerifal.cx>
Thu, 19 Oct 2017 23:04:16 +0000 (19:04 -0400)
execvpe stack-allocates a buffer used to hold the full path
(combination of a PATH entry and the program name)
while searching through $PATH, so at least
NAME_MAX+PATH_MAX is needed.

The stack size can be made conditionally smaller
(the current 1024 appears appropriate)
should this larger size be burdensome in those situations.

src/process/posix_spawn.c

index ea5d29982b8a84b3388800204b64aebdb3c4d52d..0849c71fb504b0dbf85373f93d05ebc1ae1f5a39 100644 (file)
@@ -152,7 +152,7 @@ int __posix_spawnx(pid_t *restrict res, const char *restrict path,
        char *const argv[restrict], char *const envp[restrict])
 {
        pid_t pid;
-       char stack[1024];
+       char stack[1024+PATH_MAX];
        int ec=0, cs;
        struct args args;