[or-cvs] r13057: More messing about with bug 557 issues: do not let bizarre s (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Mon Jan 7 18:54:59 UTC 2008


Author: nickm
Date: 2008-01-07 13:54:58 -0500 (Mon, 07 Jan 2008)
New Revision: 13057

Modified:
   tor/trunk/
   tor/trunk/src/or/router.c
Log:
 r17500 at catbus:  nickm | 2008-01-07 13:54:51 -0500
 More messing about with bug 557 issues: do not let bizarre settings for myfamily or contactinfo muck with generated router descriptors.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r17500] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2008-01-07 18:54:55 UTC (rev 13056)
+++ tor/trunk/src/or/router.c	2008-01-07 18:54:58 UTC (rev 13057)
@@ -1252,16 +1252,24 @@
        else
          member = router_get_by_nickname(name, 1);
        if (!member) {
+         int is_legal = is_legal_nickname_or_hexdigest(name);
          if (!smartlist_string_isin(warned_nonexistent_family, name) &&
              !is_legal_hexdigest(name)) {
-           log_warn(LD_CONFIG,
-                    "I have no descriptor for the router named \"%s\" "
-                    "in my declared family; I'll use the nickname as is, but "
-                    "this may confuse clients.", name);
+           if (is_legal)
+             log_warn(LD_CONFIG,
+                      "I have no descriptor for the router named \"%s\" in my "
+                      "declared family; I'll use the nickname as is, but "
+                      "this may confuse clients.", name);
+           else
+             log_warn(LD_CONFIG, "There is a router named \"%s\" in my "
+                      "declared family, but that isn't a legal nickname. "
+                      "Skipping it.", escaped(name));
            smartlist_add(warned_nonexistent_family, tor_strdup(name));
          }
-         smartlist_add(ri->declared_family, name);
-         name = NULL;
+         if (is_legal) {
+           smartlist_add(ri->declared_family, name);
+           name = NULL;
+         }
        } else if (router_is_me(member)) {
          /* Don't list ourself in our own family; that's redundant */
        } else {
@@ -1621,8 +1629,10 @@
   written = result;
 
   if (options->ContactInfo && strlen(options->ContactInfo)) {
-    result = tor_snprintf(s+written,maxlen-written, "contact %s\n",
-                          options->ContactInfo);
+    const char *ci = options->ContactInfo;
+    if (strchr(ci, '\n') || strchr(ci, '\r'))
+      ci = escaped(ci);
+    result = tor_snprintf(s+written,maxlen-written, "contact %s\n", ci);
     if (result<0) {
       log_warn(LD_BUG,"descriptor snprintf #2 ran out of room!");
       return -1;



More information about the tor-commits mailing list