diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-21 09:36:31 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-21 09:36:31 -0400 |
commit | 9b0a17a74f5d8cd7c5d8a07dd275e7d96bd4fd35 (patch) | |
tree | 4289c92c0b9f2833801dd5f36d3fc48d46d3ac66 /src/core/or/protover.c | |
parent | 96d1f2e6d0ebcb97aa66a1416d147533b24fac9c (diff) | |
parent | e818a7190599ff46184e1b8541b2317c145e6d8d (diff) | |
download | tor-9b0a17a74f5d8cd7c5d8a07dd275e7d96bd4fd35.tar.gz tor-9b0a17a74f5d8cd7c5d8a07dd275e7d96bd4fd35.zip |
Merge branch 'maint-0.3.4'
Diffstat (limited to 'src/core/or/protover.c')
-rw-r--r-- | src/core/or/protover.c | 15 |
1 files changed, 15 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); |