diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-21 09:35:23 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-09-21 09:35:23 -0400 |
commit | bf2ffd39781664b6b29a57a1dd1d110368f120ce (patch) | |
tree | a43d2dc3c0a86b69ad8b6848db69490ecad2ba42 /src/or/protover.c | |
parent | 04b5b87098f48c6016110b26a1cf62377437dfea (diff) | |
parent | 5b04392c1553e2a3e278a48f8d0e071181c0444f (diff) | |
download | tor-bf2ffd39781664b6b29a57a1dd1d110368f120ce.tar.gz tor-bf2ffd39781664b6b29a57a1dd1d110368f120ce.zip |
Merge branch 'maint-0.3.2' into release-0.3.2release-0.3.2
Diffstat (limited to 'src/or/protover.c')
-rw-r--r-- | src/or/protover.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/or/protover.c b/src/or/protover.c index e8524a25b5..ebaca07ba3 100644 --- a/src/or/protover.c +++ b/src/or/protover.c @@ -23,6 +23,7 @@ #define PROTOVER_PRIVATE +#include "compat.h" #include "or.h" #include "protover.h" #include "routerparse.h" @@ -170,6 +171,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. @@ -195,6 +206,10 @@ parse_single_entry(const char *s, const char *end_of_entry) if (equals == s) 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); |