[tor-commits] [tor/master] connection_describe_peer(): add nonzero ports to nonscrubbed addrs.

nickm at torproject.org nickm at torproject.org
Thu Jul 16 13:02:38 UTC 2020


commit aa33b88778c2eda110eb79cfe887621853010287
Author: Nick Mathewson <nickm at torproject.org>
Date:   Mon Jul 13 14:47:58 2020 -0400

    connection_describe_peer(): add nonzero ports to nonscrubbed addrs.
---
 src/core/mainloop/connection.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index bde002fd2e..a3cebfecdd 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -461,8 +461,15 @@ connection_describe_peer_internal(const connection_t *conn,
     }
   }
 
-  if (scrub) {
-    address = safe_str(address);
+  char portbuf[7];
+  portbuf[0]=0;
+  if (scrub && get_options()->SafeLogging_ != SAFELOG_SCRUB_NONE) {
+    address = "[scrubbed]";
+  } else {
+    /* Only set the port if we're not scrubbing the address. */
+    if (conn->port != 0) {
+      tor_snprintf(portbuf, sizeof(portbuf), ":%d", conn->port);
+    }
   }
 
   const char *sp = include_preposition ? " " : "";
@@ -470,7 +477,7 @@ connection_describe_peer_internal(const connection_t *conn,
     prep = "";
 
   tor_snprintf(peer_buf, sizeof(peer_buf),
-               "%s%s%s%s", prep, sp, address, extra_buf);
+               "%s%s%s%s%s", prep, sp, address, portbuf, extra_buf);
   return peer_buf;
 }
 





More information about the tor-commits mailing list