diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-03-07 09:32:54 -0500 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2020-03-30 13:31:44 -0400 |
commit | 84868109d2c99c349d48e29470a22c16ff7fb88e (patch) | |
tree | 570b3e5eb6ce6b463ecee3830556708ca42a62f5 | |
parent | 8aacd78e149c8228c1696a0866d09f8cba9ba250 (diff) | |
download | tor-84868109d2c99c349d48e29470a22c16ff7fb88e.tar.gz tor-84868109d2c99c349d48e29470a22c16ff7fb88e.zip |
Use SECTION_HEADER, not "HiddenServiceDir".
Add a nonfatal assertion about a branch that should be unreachable.
-rw-r--r-- | src/feature/hs/hs_config.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/feature/hs/hs_config.c b/src/feature/hs/hs_config.c index 4b55ba2af0..c799eb2086 100644 --- a/src/feature/hs/hs_config.c +++ b/src/feature/hs/hs_config.c @@ -232,6 +232,12 @@ config_learn_service_version(hs_service_t *service) return version; } +/** + * Header key indicating the start of a new hidden service configuration + * block. + **/ +static const char SECTION_HEADER[] = "HiddenServiceDir"; + /** Return true iff the given options starting at line_ for a hidden service * contains at least one invalid option. Each hidden service option don't * apply to all versions so this function can find out. The line_ MUST start @@ -286,8 +292,11 @@ config_has_invalid_options(const config_line_t *line_, for (int i = 0; optlist[i]; i++) { const char *opt = optlist[i]; for (line = line_; line; line = line->next) { - if (!strcasecmp(line->key, "HiddenServiceDir")) { - /* We just hit the next hidden service, stop right now. */ + if (!strcasecmp(line->key, SECTION_HEADER)) { + /* We just hit the next hidden service, stop right now. + * (This shouldn't be possible, now that we have partitioned the list + * into sections.) */ + tor_assert_nonfatal_unreached(); goto end; } if (!strcasecmp(line->key, opt)) { @@ -428,12 +437,6 @@ config_service_v3(const hs_opts_t *hs_opts, return -1; } -/** - * Header key indicating the start of a new hidden service configuration - * block. - **/ -static const char SECTION_HEADER[] = "HiddenServiceDir"; - /** Configure a service using the given options in hs_opts and options. This is * called for any service regardless of its version which means that all * directives in this function are generic to any service version. This @@ -462,8 +465,8 @@ config_generic_service(const hs_opts_t *hs_opts, /* Directory where the service's keys are stored. */ tor_assert(hs_opts->HiddenServiceDir); config->directory_path = tor_strdup(hs_opts->HiddenServiceDir); - log_info(LD_CONFIG, "HiddenServiceDir=%s. Configuring...", - escaped(config->directory_path)); + log_info(LD_CONFIG, "%s=%s. Configuring...", + SECTION_HEADER, escaped(config->directory_path)); /* Protocol version for the service. */ if (hs_opts->HiddenServiceVersion == -1) { |