[or-cvs] r16422: Some improvements to parsing the HiddenServiceAuthorizeClien (tor/branches/121-hs-authorization/src/or)

kloesing at seul.org kloesing at seul.org
Tue Aug 5 14:17:53 UTC 2008


Author: kloesing
Date: 2008-08-05 10:17:53 -0400 (Tue, 05 Aug 2008)
New Revision: 16422

Modified:
   tor/branches/121-hs-authorization/src/or/rendservice.c
   tor/branches/121-hs-authorization/src/or/routerparse.c
Log:
Some improvements to parsing the HiddenServiceAuthorizeClient option.

Modified: tor/branches/121-hs-authorization/src/or/rendservice.c
===================================================================
--- tor/branches/121-hs-authorization/src/or/rendservice.c	2008-08-05 14:14:45 UTC (rev 16421)
+++ tor/branches/121-hs-authorization/src/or/rendservice.c	2008-08-05 14:17:53 UTC (rev 16422)
@@ -406,7 +406,7 @@
       }
       clients = smartlist_create();
       smartlist_split_string(clients, smartlist_get(type_names_split, 1),
-                             ",", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+                             ",", SPLIT_SKIP_SPACE, 0);
       SMARTLIST_FOREACH(type_names_split, char *, cp, tor_free(cp));
       smartlist_free(type_names_split);
       if ((service->auth_type == 1 && smartlist_len(clients) > 512) ||
@@ -427,17 +427,26 @@
         rend_authorized_client_t *client;
         size_t len = strlen(client_name);
         int found_duplicate = 0;
-        if (len < 1 || len > 19 ||
-            strspn(client_name, REND_LEGAL_CLIENTNAME_CHARACTERS) != len) {
+        if (len < 1 || len > 19) {
           log_warn(LD_CONFIG, "HiddenServiceAuthorizeClient contains an "
-                   "illegal client name: '%s'. (Length must be between 1 "
-                   "and 19, and valid characters are [A-Za-z0-9+-_].)",
+                              "illegal client name: '%s'. Length must be "
+                              "between 1 and 19 characters.",
                    client_name);
           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;
+        }
         /* Check if client name is duplicate. */
         SMARTLIST_FOREACH(service->clients, rend_authorized_client_t *, c, {
           if (!strcmp(c->client_name, client_name)) {
@@ -452,6 +461,7 @@
         client = tor_malloc_zero(sizeof(rend_authorized_client_t));
         client->client_name = strdup(client_name);
         smartlist_add(service->clients, client);
+        log_debug(LD_REND, "Adding client name '%s'", client_name);
       });
       SMARTLIST_FOREACH(clients, char *, cp, tor_free(cp));
       smartlist_free(clients);

Modified: tor/branches/121-hs-authorization/src/or/routerparse.c
===================================================================
--- tor/branches/121-hs-authorization/src/or/routerparse.c	2008-08-05 14:14:45 UTC (rev 16421)
+++ tor/branches/121-hs-authorization/src/or/routerparse.c	2008-08-05 14:17:53 UTC (rev 16422)
@@ -3770,7 +3770,7 @@
   directory_token_t *tok;
   const char *current_entry = NULL;
   memarea_t *area = NULL;
-  if (!ckstr)
+  if (!ckstr || strlen(ckstr) == 0)
     return -1;
   tokens = smartlist_create();
   /* Begin parsing with first entry, skipping comments or whitespace at the



More information about the tor-commits mailing list