summaryrefslogtreecommitdiffstats
path: root/usr.bin/env/envopts.c
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2015-03-08 14:12:43 +0000
committerjilles <jilles@FreeBSD.org>2015-03-08 14:12:43 +0000
commit84c0730b384c7dbdfbb22c57d3b64272dde8da04 (patch)
tree9f7a757eed844aecbf8c6ad9ea8f2fbbbf2ecef9 /usr.bin/env/envopts.c
parenta542258e7db83d5be1c791fbb0a8614f792bb6d6 (diff)
downloadFreeBSD-src-84c0730b384c7dbdfbb22c57d3b64272dde8da04.zip
FreeBSD-src-84c0730b384c7dbdfbb22c57d3b64272dde8da04.tar.gz
env: Fix crash when -S string is not empty but no operand follows.
split_spaces() set argc in main() incorrectly, which caused trouble for getopt(). Examples: env -S '\c' env -S -i PR: 197769 MFC after: 1 week
Diffstat (limited to 'usr.bin/env/envopts.c')
-rw-r--r--usr.bin/env/envopts.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/usr.bin/env/envopts.c b/usr.bin/env/envopts.c
index f821430..5740062 100644
--- a/usr.bin/env/envopts.c
+++ b/usr.bin/env/envopts.c
@@ -372,9 +372,9 @@ str_done:
*nextarg = NULL;
/* Update optind/argc/argv in the calling routine */
- *origind = 1;
- *origc += addcount;
+ *origc += addcount - *origind + 1;
*origv = newargv;
+ *origind = 1;
}
/**
OpenPOWER on IntegriCloud