The branch main has been updated by des:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=40e52e0edd038460a2a2aca017b3ac5a513fe37b

commit 40e52e0edd038460a2a2aca017b3ac5a513fe37b
Author:     Dag-Erling Smørgrav <[email protected]>
AuthorDate: 2026-03-04 15:22:42 +0000
Commit:     Dag-Erling Smørgrav <[email protected]>
CommitDate: 2026-03-04 15:22:42 +0000

    system(3): Unwrap execve()
    
    There is no need to call execl(), which will allocate an array and copy
    our arguments into it, when we can use a static array and call execve()
    directly.
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D55648
---
 lib/libc/stdlib/system.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/libc/stdlib/system.c b/lib/libc/stdlib/system.c
index 94f7460c9b68..a2f472502bfd 100644
--- a/lib/libc/stdlib/system.c
+++ b/lib/libc/stdlib/system.c
@@ -60,6 +60,8 @@ __libc_system(const char *command)
        static struct sigaction ointact, oquitact;
        struct sigaction ign;
        sigset_t sigblock, osigblock;
+       char *argv[] = { "sh", "-c", __DECONST(char *, command), NULL };
+       extern char **environ;
        int pstat = -1, serrno = 0;
        pid_t pid;
 
@@ -101,7 +103,7 @@ __libc_system(const char *command)
                /*
                 * Exec the command.
                 */
-               execl(_PATH_BSHELL, "sh", "-c", command, NULL);
+               _execve(_PATH_BSHELL, argv, environ);
                _exit(127);
        } else {                                /* parent */
                /*

Reply via email to