aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-05 01:38:55 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-05 01:38:55 +0200
commit754e9f96defd7be48dfdc9ffe820c3fb7f35ff9e (patch)
tree07fed0afeec85d5aa19837faa30594f837bf70e1
parent9f59849daab488b5a46926a2979e8b957021e844 (diff)
downloadbusybox-754e9f96defd7be48dfdc9ffe820c3fb7f35ff9e.tar.gz
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.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/runit/sv.c b/runit/sv.c
index 3dd02550a..3267c7e4c 100644
--- a/runit/sv.c
+++ b/runit/sv.c
@@ -718,15 +718,16 @@ int svc_main(int argc UNUSED_PARAM, char **argv)
argv[1] = command;
command[1] = '\0';
- /* getopt32() was already called:
- * reset the libc getopt() function, which keeps internal state.
- */
- GETOPT_RESET();
-
do {
if (opts & 1) {
int r;
+
command[0] = *optstring;
+
+ /* getopt() was already called by getopt32():
+ * reset the libc getopt() function's internal state.
+ */
+ GETOPT_RESET();
r = sv(argv);
if (r)
return 1;