]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
execve: disallow argc == 0
authorKyle Evans <kevans@FreeBSD.org>
Tue, 25 Jan 2022 22:47:23 +0000 (16:47 -0600)
committerKyle Evans <kevans@FreeBSD.org>
Thu, 10 Feb 2022 20:21:59 +0000 (14:21 -0600)
commit7393eedb039acb7890da9743a8e8322827820b2c
tree3f57c7989b7e0a70d28a5ca538ac8d94d4a2313c
parentcd6bdac0818a44f4faceddc485e314855c0b3f11
execve: disallow argc == 0

The manpage has contained the following verbiage on the matter for just
under 31 years:

"At least one argument must be present in the array"

Previous to this version, it had been prefaced with the weakening phrase
"By convention."

Carry through and document it the rest of the way.  Allowing argc == 0
has been a source of security issues in the past, and it's hard to
imagine a valid use-case for allowing it.  Toss back EINVAL if we ended
up not copying in any args for *execve().

The manpage change can be considered "Obtained from: OpenBSD"

(cherry picked from commit 773fa8cd136a5775241c3e3a70f1997633ebeedf)
(cherry picked from commit c9afc7680f3e1f0510518de9de4264553a31aade)
lib/libc/sys/execve.2
lib/libc/tests/gen/posix_spawn_test.c
sys/kern/kern_exec.c