From 66e214d186bf50c647b8516c1f4a1a7cd40d5ea3 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Sun, 11 Mar 2018 14:47:45 +0100 Subject: Continue trying execution with "/bin/sh" for execlp and execvp As Rick stated, this isn't a clean solution because argv can be arbirtary long and overflow the stack. I post it here in case you'd find it useful anyway. --- src/process/execlp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/process/execlp.c') diff --git a/src/process/execlp.c b/src/process/execlp.c index 5eed886e..f6da398b 100644 --- a/src/process/execlp.c +++ b/src/process/execlp.c @@ -1,6 +1,9 @@ #include +#include #include +extern int __execsh(const char *, char *const []); + int execlp(const char *file, const char *argv0, ...) { int argc; @@ -17,6 +20,11 @@ int execlp(const char *file, const char *argv0, ...) argv[i] = va_arg(ap, char *); argv[i] = NULL; va_end(ap); - return execvp(file, argv); + execvp(file, argv); + if (errno == ENOEXEC) { + errno = 0; + return __execsh(file, argv); + } + return -1; } } -- cgit v1.2.3-70-g09d2