summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1996-11-18 19:24:47 +0000
committerbde <bde@FreeBSD.org>1996-11-18 19:24:47 +0000
commit998611f369590e64db3712e66fff07b6c537ce74 (patch)
tree9fd59f74b62f80f3eb78ea783bc45328692d4299 /lib
parent93424e6cf9a785301316691ee285cf3d721e80e4 (diff)
downloadFreeBSD-src-998611f369590e64db3712e66fff07b6c537ce74.zip
FreeBSD-src-998611f369590e64db3712e66fff07b6c537ce74.tar.gz
Fixed execvp() of an empty pathname to fail POSIXly. Previously it
attempted to exec the components of $PATH and it usually set errno to the wrong value. Found by: NIST PCTS
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/gen/exec.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c
index 2410ce9..72b6db4 100644
--- a/lib/libc/gen/exec.c
+++ b/lib/libc/gen/exec.c
@@ -200,6 +200,12 @@ execvp(name, argv)
}
bp = buf;
+ /* If it's an empty path name, fail in the usual POSIX way. */
+ if (*name == '\0') {
+ errno = ENOENT;
+ return (-1);
+ }
+
/* Get the path we're searching. */
if (!(path = getenv("PATH")))
path = _PATH_DEFPATH;
OpenPOWER on IntegriCloud