Module Name: src Committed By: martin Date: Mon Nov 11 06:49:31 UTC 2024
Modified Files: src/lib/libc/gen: posix_spawnp.c Log Message: Error out early if posix_spawnp(3) is called with an empty file name To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/lib/libc/gen/posix_spawnp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/gen/posix_spawnp.c diff -u src/lib/libc/gen/posix_spawnp.c:1.4 src/lib/libc/gen/posix_spawnp.c:1.5 --- src/lib/libc/gen/posix_spawnp.c:1.4 Mon May 11 14:54:34 2020 +++ src/lib/libc/gen/posix_spawnp.c Mon Nov 11 06:49:31 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: posix_spawnp.c,v 1.4 2020/05/11 14:54:34 kre Exp $ */ +/* $NetBSD: posix_spawnp.c,v 1.5 2024/11/11 06:49:31 martin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: posix_spawnp.c,v 1.4 2020/05/11 14:54:34 kre Exp $"); +__RCSID("$NetBSD: posix_spawnp.c,v 1.5 2024/11/11 06:49:31 martin Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -58,6 +58,10 @@ int posix_spawnp(pid_t * __restrict pid, _DIAGASSERT(file != NULL); + /* "" is not a valid filename; check this before traversing PATH. */ + if (file[0] == '\0') + return ENOENT; + /* * If there is a / in the name, fall straight through to posix_spawn(). */