diff options
author | teor <teor@torproject.org> | 2020-02-12 12:22:04 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2020-02-12 12:22:04 +1000 |
commit | ff52205362f5d60c209f298a3e3679bc65bdf539 (patch) | |
tree | 9f5452a584a15cb605c12b5b7d27ce7f93e52579 /src | |
parent | 00fe214729b935adc522883fa84b399429fefa74 (diff) | |
parent | 5298113da98f13cfaad4a9ab7b5ac8baa6c37279 (diff) | |
download | tor-ff52205362f5d60c209f298a3e3679bc65bdf539.tar.gz tor-ff52205362f5d60c209f298a3e3679bc65bdf539.zip |
Merge branch 'maint-0.4.1' into maint-0.4.2
Diffstat (limited to 'src')
-rw-r--r-- | src/app/config/config.c | 2 | ||||
-rw-r--r-- | src/feature/relay/router.c | 15 | ||||
-rw-r--r-- | src/test/test_config.c | 22 |
3 files changed, 30 insertions, 9 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c index deda2448b6..23781b1b0e 100644 --- a/src/app/config/config.c +++ b/src/app/config/config.c @@ -6801,7 +6801,7 @@ check_bridge_distribution_setting(const char *bd) }; unsigned i; for (i = 0; i < ARRAY_LENGTH(RECOGNIZED); ++i) { - if (!strcmp(bd, RECOGNIZED[i])) + if (!strcasecmp(bd, RECOGNIZED[i])) return 0; } diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c index ab0762e17e..a46b522bd6 100644 --- a/src/feature/relay/router.c +++ b/src/feature/relay/router.c @@ -2911,15 +2911,20 @@ router_dump_router_to_string(routerinfo_t *router, } if (options->BridgeRelay) { - const char *bd; + char *bd = NULL; + if (options->BridgeDistribution && strlen(options->BridgeDistribution)) { - bd = options->BridgeDistribution; + bd = tor_strdup(options->BridgeDistribution); } else { - bd = "any"; + bd = tor_strdup("any"); } - if (strchr(bd, '\n') || strchr(bd, '\r')) - bd = escaped(bd); + + // Make sure our value is lowercased in the descriptor instead of just + // forwarding what the user wrote in their torrc directly. + tor_strlower(bd); + smartlist_add_asprintf(chunks, "bridge-distribution-request %s\n", bd); + tor_free(bd); } if (router->onion_curve25519_pkey) { diff --git a/src/test/test_config.c b/src/test/test_config.c index cbb84e4dcf..ebc0624fb2 100644 --- a/src/test/test_config.c +++ b/src/test/test_config.c @@ -5663,11 +5663,27 @@ test_config_check_bridge_distribution_setting_not_a_bridge(void *arg) static void test_config_check_bridge_distribution_setting_valid(void *arg) { - int ret = check_bridge_distribution_setting("https"); - (void)arg; - tt_int_op(ret, OP_EQ, 0); + // Check all the possible values we support right now. + tt_int_op(check_bridge_distribution_setting("none"), OP_EQ, 0); + tt_int_op(check_bridge_distribution_setting("any"), OP_EQ, 0); + tt_int_op(check_bridge_distribution_setting("https"), OP_EQ, 0); + tt_int_op(check_bridge_distribution_setting("email"), OP_EQ, 0); + tt_int_op(check_bridge_distribution_setting("moat"), OP_EQ, 0); + + // Check all the possible values we support right now with weird casing. + tt_int_op(check_bridge_distribution_setting("NoNe"), OP_EQ, 0); + tt_int_op(check_bridge_distribution_setting("anY"), OP_EQ, 0); + tt_int_op(check_bridge_distribution_setting("hTTps"), OP_EQ, 0); + tt_int_op(check_bridge_distribution_setting("emAIl"), OP_EQ, 0); + tt_int_op(check_bridge_distribution_setting("moAt"), OP_EQ, 0); + + // Invalid values. + tt_int_op(check_bridge_distribution_setting("x\rx"), OP_EQ, -1); + tt_int_op(check_bridge_distribution_setting("x\nx"), OP_EQ, -1); + tt_int_op(check_bridge_distribution_setting("\t\t\t"), OP_EQ, -1); + done: return; } |