diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-05 01:38:55 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-05 01:40:12 +0200 |
commit | 0b16a67959244125ca495f5b7f389d14183c468e (patch) | |
tree | 61156701f22490e0bf427c05ceea4291fde6ec91 | |
parent | 4989d05174efd267d2fd85dc2e7f7beaafb8ab37 (diff) | |
download | busybox-w32-0b16a67959244125ca495f5b7f389d14183c468e.tar.gz busybox-w32-0b16a67959244125ca495f5b7f389d14183c468e.tar.bz2 busybox-w32-0b16a67959244125ca495f5b7f389d14183c468e.zip |
svc: fix a case where with more than option, getopt() state is not reset
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | runit/sv.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/runit/sv.c b/runit/sv.c index faa31d4fa..b39815613 100644 --- a/runit/sv.c +++ b/runit/sv.c | |||
@@ -718,15 +718,16 @@ int svc_main(int argc UNUSED_PARAM, char **argv) | |||
718 | argv[1] = command; | 718 | argv[1] = command; |
719 | command[1] = '\0'; | 719 | command[1] = '\0'; |
720 | 720 | ||
721 | /* getopt32() was already called: | ||
722 | * reset the libc getopt() function, which keeps internal state. | ||
723 | */ | ||
724 | GETOPT_RESET(); | ||
725 | |||
726 | do { | 721 | do { |
727 | if (opts & 1) { | 722 | if (opts & 1) { |
728 | int r; | 723 | int r; |
724 | |||
729 | command[0] = *optstring; | 725 | command[0] = *optstring; |
726 | |||
727 | /* getopt() was already called by getopt32(): | ||
728 | * reset the libc getopt() function's internal state. | ||
729 | */ | ||
730 | GETOPT_RESET(); | ||
730 | r = sv(argv); | 731 | r = sv(argv); |
731 | if (r) | 732 | if (r) |
732 | return 1; | 733 | return 1; |