summaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko2017-08-29 14:32:17 +0200
committerDenys Vlasenko2017-08-29 14:32:17 +0200
commit6016181b68a9e8a9fb99893242851128b6bd5656 (patch)
tree5aeff977b9cf7b68a32dc7e9efe183a5f7173ba6 /shell/hush.c
parent55af51c66d0dae27d188974820c4a7d53dd0be55 (diff)
downloadbusybox-6016181b68a9e8a9fb99893242851128b6bd5656.zip
busybox-6016181b68a9e8a9fb99893242851128b6bd5656.tar.gz
hush: GETOPT_RESET() _after_ getopts too.
NOEXEC'ed applets which use getopt() need this. function old new delta builtin_getopts 403 413 +10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 8e00225..d27550b 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9956,7 +9956,7 @@ Test that VAR is a valid variable name?
* until we get Nth result (or failure).
* (N == G.getopt_count is reset to 0 whenever OPTIND is [un]set).
*/
- optind = 0; /* reset getopt() state */
+ GETOPT_RESET();
count = 0;
n = string_array_len(argv);
do {
@@ -9971,6 +9971,7 @@ Test that VAR is a valid variable name?
/* Set OPTIND. Prevent resetting of the magic counter! */
set_local_var_from_halves("OPTIND", utoa(optind));
G.getopt_count = count; /* "next time, give me N+1'th result" */
+ GETOPT_RESET(); /* just in case */
/* Set OPTARG */
/* Always set or unset, never left as-is, even on exit/error: