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

[or-cvs] Use escaped() for remaining cases.



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv22042/src/or

Modified Files:
	dirserv.c or.h routerlist.c 
Log Message:
Use escaped() for remaining cases.

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.300
retrieving revision 1.301
diff -u -p -d -r1.300 -r1.301
--- dirserv.c	8 Mar 2006 06:29:52 -0000	1.300
+++ dirserv.c	11 Mar 2006 02:21:30 -0000	1.301
@@ -347,12 +347,14 @@ dirserv_get_status_impl(const char *fp, 
     return FP_NAMED; /* Right fingerprint. */
   } else {
     if (should_log) {
+      char *esc_contact = esc_for_log(contact);
       log_warn(LD_DIRSERV,
                "Mismatched fingerprint for '%s': expected '%s' got '%s'. "
                "ContactInfo '%s', platform '%s'.)",
                nickname, nn_ent->fingerprint, fp,
-               contact ? contact : "",
+               esc_contact,
                platform ? escaped(platform) : "");
+       tor_free(esc_contact);
     }
     if (msg)
       *msg = "Rejected: There is already a verified server with this nickname "
@@ -449,10 +451,9 @@ authdir_wants_to_reject_router(routerinf
   if (ri->cache_info.published_on > now+ROUTER_ALLOW_SKEW) {
     log_fn(severity, LD_DIRSERV, "Publication time for nickname '%s' is too "
            "far (%d minutes) in the future; possible clock skew. Not adding "
-           "(ContactInfo '%s', platform '%s').",
+           "(%s)",
            ri->nickname, (int)((ri->cache_info.published_on-now)/60),
-           ri->contact_info ? ri->contact_info : "",
-           ri->platform ? ri->platform : "");
+           esc_router_info(ri));
     *msg = "Rejected: Your clock is set too far in the future, or your "
       "timezone is not correct.";
     return -1;
@@ -460,11 +461,9 @@ authdir_wants_to_reject_router(routerinf
   if (ri->cache_info.published_on < now-ROUTER_MAX_AGE_TO_PUBLISH) {
     log_fn(severity, LD_DIRSERV,
            "Publication time for router with nickname '%s' is too far "
-           "(%d minutes) in the past. Not adding (ContactInfo '%s', "
-           "platform '%s').",
+           "(%d minutes) in the past. Not adding (%s)",
            ri->nickname, (int)((now-ri->cache_info.published_on)/60),
-           ri->contact_info ? ri->contact_info : "",
-           ri->platform ? ri->platform : "");
+           esc_router_info(ri));
     *msg = "Rejected: Server is expired, or your clock is too far in the past,"
       " or your timezone is not correct.";
     return -1;
@@ -472,10 +471,9 @@ authdir_wants_to_reject_router(routerinf
   if (dirserv_router_has_valid_address(ri) < 0) {
     log_fn(severity, LD_DIRSERV,
            "Router with nickname '%s' has invalid address '%s'. "
-           "Not adding (ContactInfo '%s', platform '%s').",
+           "Not adding (%s).",
            ri->nickname, ri->address,
-           ri->contact_info ? ri->contact_info : "",
-           ri->platform ? ri->platform : "");
+           esc_router_info(ri));
     *msg = "Rejected: Address is not an IP, or IP is a private address.";
     return -1;
   }

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.801
retrieving revision 1.802
diff -u -p -d -r1.801 -r1.802
--- or.h	9 Mar 2006 00:18:16 -0000	1.801
+++ or.h	11 Mar 2006 02:21:30 -0000	1.802
@@ -2362,6 +2362,7 @@ void networkstatus_list_update_recent(ti
 void router_reset_descriptor_download_failures(void);
 void router_reset_status_download_failures(void);
 int router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2);
+const char *esc_router_info(routerinfo_t *router);
 
 /********************************* routerparse.c ************************/
 

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.450
retrieving revision 1.451
diff -u -p -d -r1.450 -r1.451
--- routerlist.c	8 Mar 2006 06:29:52 -0000	1.450
+++ routerlist.c	11 Mar 2006 02:21:30 -0000	1.451
@@ -3792,3 +3792,25 @@ routerlist_assert_ok(routerlist_t *rl)
   }
 }
 
+const char *
+esc_router_info(routerinfo_t *router)
+{
+  static char *info;
+  char *esc_contact, *esc_platform;
+  size_t len;
+  if (info)
+    tor_free(info);
+
+  esc_contact = esc_for_log(router->contact_info);
+  esc_platform = esc_for_log(router->platform);
+
+  len = strlen(esc_contact)+strlen(esc_platform)+32;
+  info = tor_malloc(len);
+  tor_snprintf(info, len, "Contact %s, Platform %s", esc_contact,
+               esc_platform);
+  tor_free(esc_contact);
+  tor_free(esc_platform);
+
+  return info;
+}
+