From d8fca8321e265a25b7d88c1af5e25d534592d801 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 29 Dec 2019 14:25:40 +0100 Subject: [PATCH] mescc: Mes C Library: Fix execlp, execvp for file names with slash. Reported by mid-kid. * lib/posix/execlp.c (execlp): Do not use search_path when file name contains a slash (WAS: when file name starts with slash). * lib/posix/execvp.c (execvp): Likewise. --- lib/posix/execlp.c | 3 ++- lib/posix/execvp.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/posix/execlp.c b/lib/posix/execlp.c index 48a239ae..904b586b 100644 --- a/lib/posix/execlp.c +++ b/lib/posix/execlp.c @@ -21,6 +21,7 @@ #include #include #include +#include int execlp (char const *file_name, char const *arg, ...) @@ -28,7 +29,7 @@ execlp (char const *file_name, char const *arg, ...) va_list ap; int r; va_start (ap, arg); - if (file_name[0] != '/') + if (!strchr (file_name, '/')) file_name = search_path (file_name); if (__mes_debug () > 2) { diff --git a/lib/posix/execvp.c b/lib/posix/execvp.c index 8d906a5a..3facc1ff 100644 --- a/lib/posix/execvp.c +++ b/lib/posix/execvp.c @@ -20,12 +20,13 @@ #include #include +#include #include int execvp (char const *file_name, char *const argv[]) { - if (file_name[0] != '/') + if (!strchr (file_name, '/')) file_name = search_path (file_name); if (!file_name) {