summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Hall <halex@cvs.openbsd.org>2015-12-27 09:24:01 +0000
committerAlexander Hall <halex@cvs.openbsd.org>2015-12-27 09:24:01 +0000
commit0686eda1d4c734f1e773c5dafaa94eb21fd28611 (patch)
tree47f2aa69d8222e1ce1407d207bfb44860459a94e
parent720267282fe64550141b5ceb281072e007c6bd47 (diff)
unconditionally duplicate the argv array on initialization, to make it
resilient against being altered by a subsequent shift operation tweak and ok semarie@
-rw-r--r--bin/ksh/main.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/bin/ksh/main.c b/bin/ksh/main.c
index 8692c412418..200931820a6 100644
--- a/bin/ksh/main.c
+++ b/bin/ksh/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.75 2015/12/14 13:59:42 tb Exp $ */
+/* $OpenBSD: main.c,v 1.76 2015/12/27 09:24:00 halex Exp $ */
/*
* startup, main loop, environments and error handling
@@ -127,15 +127,13 @@ static char **
make_argv(int argc, char *argv[])
{
int i;
- char **nargv = argv;
-
- if (strcmp(argv[0], kshname) != 0) {
- nargv = areallocarray(NULL, argc + 1, sizeof(char *), &aperm);
- nargv[0] = (char *) kshname;
- for (i = 1; i < argc; i++)
- nargv[i] = argv[i];
- nargv[i] = NULL;
- }
+ char **nargv;
+
+ nargv = areallocarray(NULL, argc + 1, sizeof(char *), &aperm);
+ nargv[0] = (char *) kshname;
+ for (i = 1; i < argc; i++)
+ nargv[i] = argv[i];
+ nargv[i] = NULL;
return nargv;
}