diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-12-07 16:40:19 -0500 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2020-12-08 16:53:57 +0200 |
commit | 558aaf1c32ece99f62006c6a3395c3e53d5e414d (patch) | |
tree | 4eb8291c335a5caa0109d5a7bdee746b9e459d9c /src/app/config/config.c | |
parent | b50fcdc2e79e5ab639af5f53d74a4d2474821223 (diff) | |
download | tor-558aaf1c32ece99f62006c6a3395c3e53d5e414d.tar.gz tor-558aaf1c32ece99f62006c6a3395c3e53d5e414d.zip |
Command-line arguments: be better at detecting absent optional args.
Previously, "--list-fingerprint --quiet" was an error. Now, the
handler for optional arguments to "--list-fingerprint" can tell that
"--quiet" is a flag, not an argument.
This only affects flags that take an _optional_ argument, so you can
still put your torrc file in a location starting with "-".
Closes #40223.
Diffstat (limited to 'src/app/config/config.c')
-rw-r--r-- | src/app/config/config.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c index df89b6ede9..660c89bc4c 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -2601,8 +2601,11 @@ config_parse_commandline(int argc, char **argv, int ignore_errors) parsed_cmdline_free(result); return NULL; } - } else if (want_arg == ARGUMENT_OPTIONAL && is_last) { + } else if (want_arg == ARGUMENT_OPTIONAL && + /* optional arguments may never start with '-'. */ + (is_last || argv[i+1][0] == '-')) { arg = tor_strdup(""); + want_arg = ARGUMENT_NONE; // prevent skipping the next flag. } else { arg = (want_arg != ARGUMENT_NONE) ? tor_strdup(argv[i+1]) : tor_strdup(""); |