Commit fcbd65b4 authored by Nick Mathewson's avatar Nick Mathewson 🦀
Browse files

Refactor the safe_str_*() API to make more sense.

The new rule is: safe_str_X() means "this string is a piece of X
information; make it safe to log."  safe_str() on its own means
"this string is a piece of who-knows-what; make it safe to log".
parent a8190b09
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1491,7 +1491,7 @@ fetch_from_buf_socks(buf_t *buf, socks_request_t *req,
        }
        log_debug(LD_APP,
                  "socks4: successfully read destip (%s)",
                  safe_str(tmpbuf));
                  safe_str_client(tmpbuf));
        socks4_prot = socks4;
      }

+1 −1
Original line number Diff line number Diff line
@@ -1230,7 +1230,7 @@ circuit_handle_first_hop(origin_circuit_t *circ)
    const char *name = strlen(firsthop->extend_info->nickname) ?
      firsthop->extend_info->nickname : fmt_addr(&firsthop->extend_info->addr);
    log_info(LD_CIRC, "Next router is %s: %s ",
             safe_str(name), msg?msg:"???");
             safe_str_client(name), msg?msg:"???");
    circ->_base.n_hop = extend_info_dup(firsthop->extend_info);

    if (should_launch) {
+3 −3
Original line number Diff line number Diff line
@@ -1090,8 +1090,8 @@ _circuit_mark_for_close(circuit_t *circ, int reason, int line,
    /* treat this like getting a nack from it */
    log_info(LD_REND, "Failed intro circ %s to %s (awaiting ack). "
           "Removing from descriptor.",
             safe_str(ocirc->rend_data->onion_address),
             safe_str(build_state_get_exit_nickname(ocirc->build_state)));
           safe_str_client(ocirc->rend_data->onion_address),
           safe_str_client(build_state_get_exit_nickname(ocirc->build_state)));
    rend_client_remove_intro_point(ocirc->build_state->chosen_exit,
                                   ocirc->rend_data);
  }
+5 −5
Original line number Diff line number Diff line
@@ -1103,7 +1103,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
                                                need_uptime)) {
        log_notice(LD_APP,
                   "No Tor server allows exit to %s:%d. Rejecting.",
                   safe_str(conn->socks_request->address),
                   safe_str_client(conn->socks_request->address),
                   conn->socks_request->port);
        return -1;
      }
@@ -1144,14 +1144,14 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
      if (!extend_info) {
        log_info(LD_REND,
                 "No intro points for '%s': re-fetching service descriptor.",
                 safe_str(conn->rend_data->onion_address));
                 safe_str_client(conn->rend_data->onion_address));
        rend_client_refetch_v2_renddesc(conn->rend_data);
        conn->_base.state = AP_CONN_STATE_RENDDESC_WAIT;
        return 0;
      }
      log_info(LD_REND,"Chose '%s' as intro point for '%s'.",
               extend_info->nickname,
               safe_str(conn->rend_data->onion_address));
               safe_str_client(conn->rend_data->onion_address));
    }

    /* If we have specified a particular exit node for our
@@ -1180,7 +1180,7 @@ circuit_get_open_circ_or_launch(edge_connection_t *conn,
            }
            if (tor_addr_from_str(&addr, conn->socks_request->address) < 0) {
              log_info(LD_DIR, "Broken address %s on tunnel conn. Closing.",
                       escaped_safe_str(conn->socks_request->address));
                       escaped_safe_str_client(conn->socks_request->address));
              return -1;
            }
            extend_info = extend_info_alloc(conn->chosen_exit_name+1,
@@ -1405,7 +1405,7 @@ connection_ap_handshake_attach_circuit(edge_connection_t *conn)
      LOG_INFO : LOG_NOTICE;
    log_fn(severity, LD_APP,
           "Tried for %d seconds to get a connection to %s:%d. Giving up.",
           conn_age, safe_str(conn->socks_request->address),
           conn_age, safe_str_client(conn->socks_request->address),
           conn->socks_request->port);
    return -1;
  }
+3 −3
Original line number Diff line number Diff line
@@ -405,7 +405,7 @@ command_process_relay_cell(cell_t *cell, or_connection_t *conn)
        log_fn(LOG_PROTOCOL_WARN, LD_OR,
               "Received too many RELAY_EARLY cells on circ %d from %s:%d."
               "  Closing circuit.",
               cell->circ_id, safe_str_relay(conn->_base.address),
               cell->circ_id, safe_str(conn->_base.address),
               conn->_base.port);
        circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
        return;
@@ -515,7 +515,7 @@ command_process_versions_cell(var_cell_t *cell, or_connection_t *conn)

  log_info(LD_OR, "Negotiated version %d with %s:%d; sending NETINFO.",
           highest_supported_version,
           safe_str(conn->_base.address),
           safe_str_client(conn->_base.address),
           conn->_base.port);
  tor_assert(conn->link_proto >= 2);

@@ -629,7 +629,7 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t *conn)
  else
    log_info(LD_OR, "Got good NETINFO cell from %s:%d; OR connection is now "
             "open, using protocol version %d",
             safe_str(conn->_base.address),
             safe_str_client(conn->_base.address),
             conn->_base.port, (int)conn->link_proto);
  assert_connection_ok(TO_CONN(conn),time(NULL));
}
Loading