client: fix parsing of -v command option

The sources and sourcestats commands accept -v as an option, but the
glibc implementation of getopt() reorders the arguments and parses the
option as a command-line option of chronyc.

Add '+' to the getopt string to disable this feature. Other getopt()
implementations should consider it a new command-line option, which will
be handled as an error if present.
This commit is contained in:
Miroslav Lichvar 2017-08-08 14:08:30 +02:00
parent 1c51feb3c5
commit 93076e7e1c

View file

@ -3143,7 +3143,7 @@ main(int argc, char **argv)
optind = 1;
/* Parse short command-line options */
while ((opt = getopt(argc, argv, "46acdf:h:mnp:v")) != -1) {
while ((opt = getopt(argc, argv, "+46acdf:h:mnp:v")) != -1) {
switch (opt) {
case '4':
case '6':