[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r16439: {tor} A couple of smaller fixes. (tor/branches/121-hs-authorization/src/or)



Author: kloesing
Date: 2008-08-05 19:10:13 -0400 (Tue, 05 Aug 2008)
New Revision: 16439

Modified:
   tor/branches/121-hs-authorization/src/or/rendservice.c
   tor/branches/121-hs-authorization/src/or/routerparse.c
Log:
A couple of smaller fixes.

Modified: tor/branches/121-hs-authorization/src/or/rendservice.c
===================================================================
--- tor/branches/121-hs-authorization/src/or/rendservice.c	2008-08-05 22:56:45 UTC (rev 16438)
+++ tor/branches/121-hs-authorization/src/or/rendservice.c	2008-08-05 23:10:13 UTC (rev 16439)
@@ -387,18 +387,21 @@
         return -1;
       }
       if (smartlist_len(type_names_split) < 2) {
-        log_info(LD_CONFIG, "HiddenServiceAuthorizeClient contains "
-                            "authorization type %d, but no client names; "
-                            "hidden service won't be advertised.",
+        log_warn(LD_CONFIG, "HiddenServiceAuthorizeClient contains "
+                            "authorization type %d, but no client names.",
                  service->auth_type);
         SMARTLIST_FOREACH(type_names_split, char *, cp, tor_free(cp));
         smartlist_free(type_names_split);
         continue;
       }
       if (smartlist_len(type_names_split) > 2) {
-        log_warn(LD_CONFIG, "HiddenServiceAuthorizeClient must be formatted "
-                 "as 'HiddenServiceAuthorizeClient auth-type client-name,"
-                 "client-name,...'.");
+        log_warn(LD_CONFIG, "HiddenServiceAuthorizeClient contains "
+                            "illegal value '%s'. Must be formatted "
+                            "as 'HiddenServiceAuthorizeClient auth-type "
+                            "client-name,client-name,...' (without "
+                            "additional spaces in client-separated client "
+                            "list).",
+                 line->value);
         SMARTLIST_FOREACH(type_names_split, char *, cp, tor_free(cp));
         smartlist_free(type_names_split);
         rend_service_free(service);
@@ -406,7 +409,7 @@
       }
       clients = smartlist_create();
       smartlist_split_string(clients, smartlist_get(type_names_split, 1),
-                             ",", SPLIT_SKIP_SPACE, 0);
+                             ",", 0, 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) ||
@@ -618,10 +621,18 @@
         return -1;
       }
       client_keys_str = read_file_to_str(cfname, RFTS_IGNORE_MISSING, NULL);
-      rend_parse_client_keys(parsed_clients, client_keys_str);
-      tor_free(client_keys_str);
-      log_info(LD_CONFIG, "Parsed %d previously stored client entries.",
-          strmap_size(parsed_clients));
+      if (client_keys_str) {
+        if (rend_parse_client_keys(parsed_clients, client_keys_str) < 0) {
+          log_warn(LD_CONFIG, "Previously stored client_keys file could not "
+                              "be parsed.");
+          tor_free(client_keys_str);
+          return -1;
+        } else {
+          log_info(LD_CONFIG, "Parsed %d previously stored client entries.",
+                   strmap_size(parsed_clients));
+          tor_free(client_keys_str);
+        }
+      }
 
       /* Prepare client_keys and hostname files. */
       if (write_str_to_file(cfname, "", 0) < 0) {
@@ -681,6 +692,7 @@
           client->client_key = prkey;
         }
         /* Add entry to client_keys file. */
+        desc_cook_out[strlen(desc_cook_out)-1] = '\0'; /* Remove newline. */
         written = tor_snprintf(buf, sizeof(buf),
                                "client-name %s\ndescriptor-cookie %s\n",
                                client->client_name, desc_cook_out);
@@ -726,8 +738,8 @@
           tor_snprintf(buf, sizeof(buf),"%s.onion %s # client: %s\n",
                        service_id, desc_cook_out, client->client_name);
         } else {
-          desc_cook_out[strlen(desc_cook_out)-3] = '\0'; /* Remove == signs
-                                                            and newline. */
+          /* Remove == signs (newline has been removed above). */
+          desc_cook_out[strlen(desc_cook_out)-2] = '\0';
           tor_snprintf(buf, sizeof(buf),"%s.onion %s # client: %s\n",
                        s->service_id, desc_cook_out, client->client_name);
         }

Modified: tor/branches/121-hs-authorization/src/or/routerparse.c
===================================================================
--- tor/branches/121-hs-authorization/src/or/routerparse.c	2008-08-05 22:56:45 UTC (rev 16438)
+++ tor/branches/121-hs-authorization/src/or/routerparse.c	2008-08-05 23:10:13 UTC (rev 16439)
@@ -3624,12 +3624,12 @@
     int declen;
     log_debug(LD_REND, "Introduction points are encrypted for "
                        "authorization type 2.");
-    dec = tor_malloc_zero(ipos_encrypted_size - 16);
+    dec = tor_malloc_zero(ipos_encrypted_size - 16 - 1);
     cipher = crypto_create_init_cipher(descriptor_cookie, 0);
     declen = crypto_cipher_decrypt_with_iv(cipher, dec,
-                                           ipos_encrypted_size - 16,
-                                           ipos_encrypted,
-                                           ipos_encrypted_size);
+                                           ipos_encrypted_size - 16 - 1,
+                                           ipos_encrypted + 1,
+                                           ipos_encrypted_size - 1);
     crypto_free_cipher_env(cipher);
     if (declen < 0) {
       log_warn(LD_REND, "Decrypting introduction points failed!");