From 4a61fabf489b8c384342c31bf29087e298c9246c Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 9 Jun 2025 23:47:11 -0400 Subject: usr.bin: osh: Check bin_path with access() Signed-off-by: Ian Moffett --- usr.bin/osh/osh.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'usr.bin') diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c index 4064c12..93ac876 100644 --- a/usr.bin/osh/osh.c +++ b/usr.bin/osh/osh.c @@ -222,6 +222,12 @@ cmd_run(const char *input, int argc, char *argv[]) int error; snprintf(bin_path, sizeof(bin_path), "/usr/bin/%s", input); + + /* See if we can access it */ + if (access(bin_path, F_OK) != 0) { + return -1; + } + if ((error = spawn(bin_path, SPAWN_WAIT)) < 0) { return error; } -- cgit v1.2.3