From 1e462729c1bc7325bb1126a674d1fb7b91cf836a Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Wed, 19 Jul 2017 22:46:03 +0300 Subject: Add support for -- argument termination marker This allows one to have executables starting with -; another side-effect of this patch is that in case dtach is used in a script where we can't trust the user input, now the user is not able to inject new options that are interpreted by dtach; (for example it is used like dtach -c socket -- ${@} (cherry picked from commit ff35a7e791225f8d28a27033658070bbb4caa5ff) --- main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.c b/main.c index 9fe78b8..89e22ce 100644 --- a/main.c +++ b/main.c @@ -152,6 +152,11 @@ main(int argc, char **argv) { char *p; + if (strcmp(argv[0], "--") == 0) { + ++argv; --argc; + break; + } + for (p = argv[0] + 1; *p; ++p) { if (*p == 'E') -- cgit v1.2.3