summaryrefslogtreecommitdiff
path: root/src/or/rendservice.c
diff options
context:
space:
mode:
authorJohn Brooks <john.brooks@dereferenced.net>2016-02-19 16:32:25 -0700
committerNick Mathewson <nickm@torproject.org>2016-05-09 14:30:34 -0400
commit162aa14eef69bc97233d6b2c47bc1317e30f9364 (patch)
treec8b768498d077a262e491b0fe4725933893b5160 /src/or/rendservice.c
parentdcc11674db53cc89228ec2e8d49f30bdf6c9b8a3 (diff)
downloadtor-162aa14eef69bc97233d6b2c47bc1317e30f9364.tar.gz
tor-162aa14eef69bc97233d6b2c47bc1317e30f9364.zip
Move rend client name checks to one function
Diffstat (limited to 'src/or/rendservice.c')
-rw-r--r--src/or/rendservice.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 5b9320922b..030c836e78 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -672,27 +672,17 @@ rend_config_services(const or_options_t *options, int validate_only)
SMARTLIST_FOREACH_BEGIN(clients, const char *, client_name)
{
rend_authorized_client_t *client;
- size_t len = strlen(client_name);
- if (len < 1 || len > REND_CLIENTNAME_MAX_LEN) {
+ if (!rend_valid_client_name(client_name)) {
log_warn(LD_CONFIG, "HiddenServiceAuthorizeClient contains an "
- "illegal client name: '%s'. Length must be "
- "between 1 and %d characters.",
+ "illegal client name: '%s'. Names must be "
+ "between 1 and %d characters and contain "
+ "only [A-Za-z0-9+_-].",
client_name, REND_CLIENTNAME_MAX_LEN);
SMARTLIST_FOREACH(clients, char *, cp, tor_free(cp));
smartlist_free(clients);
rend_service_free(service);
return -1;
}
- if (strspn(client_name, REND_LEGAL_CLIENTNAME_CHARACTERS) != len) {
- log_warn(LD_CONFIG, "HiddenServiceAuthorizeClient contains an "
- "illegal client name: '%s'. Valid "
- "characters are [A-Za-z0-9+_-].",
- client_name);
- SMARTLIST_FOREACH(clients, char *, cp, tor_free(cp));
- smartlist_free(clients);
- rend_service_free(service);
- return -1;
- }
client = tor_malloc_zero(sizeof(rend_authorized_client_t));
client->client_name = tor_strdup(client_name);
smartlist_add(service->clients, client);