diff options
author | Quentin Rameau <quinq@fifth.space> | 2018-03-11 14:47:45 +0100 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2023-05-05 21:21:38 -0500 |
commit | 66e214d186bf50c647b8516c1f4a1a7cd40d5ea3 (patch) | |
tree | bd0d4d97d998ec3337b740f2f9e9ad2f1ccb8f6a /src/process/execsh.c | |
parent | b1e554e906de3486d5ee82903cb61d4bfc6d4fab (diff) | |
download | musl-66e214d186bf50c647b8516c1f4a1a7cd40d5ea3.tar.gz musl-66e214d186bf50c647b8516c1f4a1a7cd40d5ea3.tar.bz2 musl-66e214d186bf50c647b8516c1f4a1a7cd40d5ea3.tar.xz musl-66e214d186bf50c647b8516c1f4a1a7cd40d5ea3.zip |
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.
Diffstat (limited to 'src/process/execsh.c')
-rw-r--r-- | src/process/execsh.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/process/execsh.c b/src/process/execsh.c new file mode 100644 index 00000000..180bb2aa --- /dev/null +++ b/src/process/execsh.c @@ -0,0 +1,18 @@ +#include <unistd.h> +#include <errno.h> +#include "libc.h" + +int +__execsh(const char *file, char *const argv[]) +{ + int i, argc; + char **p; + + for (argc=1, p=(char **)argv; *p; ++argc, ++p); + + char *nargv[argc+1]; + nargv[0] = (char *)file; + for (i=0; i<argc; ++i) + nargv[i+1] = argv[i]; + return execv("/bin/sh", nargv); +} |