From nobody Wed Mar 11 14:01:30 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4fWC930pT9z6VD2k; Wed, 11 Mar 2026 14:01:43 +0000 (UTC) (envelope-from fuz@fuz.su) Received: from fuz.su (fuz.su [IPv6:2001:41d0:8:e508::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "fuz.su", Issuer "fuz.su" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fWC8z6GHhz4JJr; Wed, 11 Mar 2026 14:01:39 +0000 (UTC) (envelope-from fuz@fuz.su) Authentication-Results: mx1.freebsd.org; none Received: from fuz.su (localhost [127.0.0.1]) by fuz.su (8.18.1/8.18.1) with ESMTPS id 62BE1UbB025154 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 11 Mar 2026 15:01:30 +0100 (CET) (envelope-from fuz@fuz.su) Received: (from fuz@localhost) by fuz.su (8.18.1/8.18.1/Submit) id 62BE1U2Y025153; Wed, 11 Mar 2026 15:01:30 +0100 (CET) (envelope-from fuz) Date: Wed, 11 Mar 2026 15:01:30 +0100 From: Robert Clausecker To: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-branches@freebsd.org Subject: Re: git: 3d394a1da079 - stable/15 - system(3): Unwrap execve() Message-ID: References: <69b16b36.275ef.6ffc5448@gitrepo.freebsd.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <69b16b36.275ef.6ffc5448@gitrepo.freebsd.org> X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:16276, ipnet:2001:41d0::/32, country:FR] X-Rspamd-Queue-Id: 4fWC8z6GHhz4JJr X-Spamd-Bar: ---- Hi des, Am Wed, Mar 11, 2026 at 01:16:38PM +0000 schrieb Dag-Erling Smørgrav: > The branch stable/15 has been updated by des: > > URL: https://cgit.FreeBSD.org/src/commit/?id=3d394a1da0798cbe8fa07bbc92dab14ad4c4fff1 > > commit 3d394a1da0798cbe8fa07bbc92dab14ad4c4fff1 > Author: Dag-Erling Smørgrav > AuthorDate: 2026-03-04 15:22:42 +0000 > Commit: Dag-Erling Smørgrav > CommitDate: 2026-03-11 13:16:00 +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 > > (cherry picked from commit 40e52e0edd038460a2a2aca017b3ac5a513fe37b) > --- > 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 }; How about > + const char *argv[] = { "sh", "-c", command, NULL }; instead? > + 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 */ > /* Yours, Robert Clausecker -- () ascii ribbon campaign - for an encoding-agnostic world /\ - against html email - against proprietary attachments