tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit 8fbafd14021c9c9ec9b2e3f57752b96b8d2c809d
parent ba7816db5f55d76e925c2edcbbbe689490d85650
Author: Nick Mathewson <nickm@torproject.org>
Date:   Mon, 13 Jul 2020 14:42:30 -0400

Apply SafeLogging in connection_describe_peer().

Diffstat:
Msrc/core/mainloop/connection.c | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c @@ -389,6 +389,7 @@ connection_describe_peer_internal(const connection_t *conn, const tor_addr_t *addr = &conn->addr; const char *address = NULL; const char *prep; + bool scrub = false; char extra_buf[128]; extra_buf[0] = 0; @@ -423,6 +424,7 @@ connection_describe_peer_internal(const connection_t *conn, /* We report the IDs we're talking to... */ if (fast_digest_is_zero(or_conn->identity_digest)) { strlcpy(id_buf, "unknown", sizeof(id_buf)); + scrub = true; // This could be a client, so scrub it. } else { base16_encode(id_buf, sizeof(id_buf), or_conn->identity_digest, DIGEST_LEN); @@ -439,6 +441,7 @@ connection_describe_peer_internal(const connection_t *conn, } } } else if (conn->type == CONN_TYPE_EXIT) { + scrub = true; /* This is a client's request; scrub it with SafeLogging. */ if (tor_addr_is_null(addr)) { address = conn->address; strlcpy(extra_buf, " (DNS lookup pending)", sizeof(extra_buf)); @@ -458,6 +461,10 @@ connection_describe_peer_internal(const connection_t *conn, } } + if (scrub) { + address = safe_str(address); + } + const char *sp = include_preposition ? " " : ""; if (! include_preposition) prep = "";