diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/or/protover.c | 15 | ||||
-rw-r--r-- | src/feature/nodelist/nodelist.c | 5 | ||||
-rw-r--r-- | src/test/test_protover.c | 4 |
3 files changed, 24 insertions, 0 deletions
diff --git a/src/core/or/protover.c b/src/core/or/protover.c index 0f6f0e79ff..f0791366fe 100644 --- a/src/core/or/protover.c +++ b/src/core/or/protover.c @@ -179,6 +179,16 @@ parse_version_range(const char *s, const char *end_of_range, return -1; } +static int +is_valid_keyword(const char *s, size_t n) +{ + for (size_t i = 0; i < n; i++) { + if (!TOR_ISALNUM(s[i]) && s[i] != '-') + return 0; + } + return 1; +} + /** Parse a single protocol entry from <b>s</b> up to an optional * <b>end_of_entry</b> pointer, and return that protocol entry. Return NULL * on error. @@ -213,6 +223,11 @@ parse_single_entry(const char *s, const char *end_of_entry) MAX_PROTOCOL_NAME_LENGTH, escaped(out->name)); goto error; } + + /* The name must contain only alphanumeric characters and hyphens. */ + if (!is_valid_keyword(s, equals-s)) + goto error; + out->name = tor_strndup(s, equals-s); tor_assert(equals < end_of_entry); diff --git a/src/feature/nodelist/nodelist.c b/src/feature/nodelist/nodelist.c index ac9821d827..ce77d71c64 100644 --- a/src/feature/nodelist/nodelist.c +++ b/src/feature/nodelist/nodelist.c @@ -1144,6 +1144,11 @@ node_supports_v3_rendezvous_point(const node_t *node) { tor_assert(node); + /* We can't use a v3 rendezvous point without the curve25519 onion pk. */ + if (!node_get_curve25519_onion_key(node)) { + return 0; + } + return node_get_protover_summary_flags(node)->supports_v3_rendezvous_point; } diff --git a/src/test/test_protover.c b/src/test/test_protover.c index 123faccdab..b835e28ab5 100644 --- a/src/test/test_protover.c +++ b/src/test/test_protover.c @@ -554,6 +554,10 @@ test_protover_vote_roundtrip(void *args) const char *input; const char *expected_output; } examples[] = { + { "Risqu\u00e9=1", NULL }, + { ",,,=1", NULL }, + { "\xc1=1", NULL }, + { "Foo_Bar=1", NULL }, { "Fkrkljdsf", NULL }, { "Zn=4294967295", NULL }, { "Zn=4294967295-1", NULL }, |