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

[tor-commits] [tor/master] Fix 8447: use %u to format circid_t.



commit 339df5df085e2115c01881cf628abe5ed3fbd456
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Sun Mar 10 08:32:58 2013 -0400

    Fix 8447: use %u to format circid_t.
    
    Now that circid_t is 4 bytes long, the default integer promotions will
    leave it alone when sizeof(int) == 4, which will leave us formatting an
    unsigned as an int.  That's technically undefined behavior.
    
    Fixes bug 8447 on bfffc1f0fc7616a25c32da2eb759dade4651659e.  Bug not
    in any released Tor.
---
 src/or/channel.c         |    8 +++---
 src/or/circuitbuild.c    |    2 +-
 src/or/circuitlist.c     |   30 +++++++++++-----------
 src/or/circuitmux.c      |   22 ++++++++--------
 src/or/circuituse.c      |   61 ++++++++++++++++++++++++----------------------
 src/or/command.c         |   34 +++++++++++++------------
 src/or/connection_edge.c |   12 ++++----
 src/or/connection_or.c   |    1 -
 src/or/cpuworker.c       |    5 +--
 src/or/rendclient.c      |   12 ++++----
 src/or/rendmid.c         |   58 ++++++++++++++++++++++----------------------
 src/or/rendservice.c     |   54 ++++++++++++++++++++++------------------
 12 files changed, 154 insertions(+), 145 deletions(-)

diff --git a/src/or/channel.c b/src/or/channel.c
index f8afc40..82db061 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -2607,17 +2607,17 @@ channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)
     cell.command = CELL_DESTROY;
     cell.payload[0] = (uint8_t) reason;
     log_debug(LD_OR,
-              "Sending destroy (circID %d) on channel %p "
+              "Sending destroy (circID %u) on channel %p "
               "(global ID " U64_FORMAT ")",
-              circ_id, chan,
+              (unsigned)circ_id, chan,
               U64_PRINTF_ARG(chan->global_identifier));
 
     channel_write_cell(chan, &cell);
   } else {
     log_warn(LD_BUG,
-             "Someone called channel_send_destroy() for circID %d "
+             "Someone called channel_send_destroy() for circID %u "
              "on a channel " U64_FORMAT " at %p in state %s (%d)",
-             circ_id, U64_PRINTF_ARG(chan->global_identifier),
+             (unsigned)circ_id, U64_PRINTF_ARG(chan->global_identifier),
              chan, channel_state_to_string(chan->state),
              chan->state);
   }
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 8a3a36a..fbe94a9 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -523,7 +523,7 @@ circuit_deliver_create_cell(circuit_t *circ, const create_cell_t *create_cell,
     log_warn(LD_CIRC,"failed to get unique circID.");
     return -1;
   }
-  log_debug(LD_CIRC,"Chosen circID %u.", id);
+  log_debug(LD_CIRC,"Chosen circID %u.", (unsigned)id);
   circuit_set_n_circid_chan(circ, id, circ->n_chan);
 
   memset(&cell, 0, sizeof(cell_t));
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index ef32680..17e18c7 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -780,13 +780,13 @@ circuit_dump_conn_details(int severity,
                           circuit_t *circ,
                           int conn_array_index,
                           const char *type,
-                          int this_circid,
-                          int other_circid)
+                          circid_t this_circid,
+                          circid_t other_circid)
 {
-  tor_log(severity, LD_CIRC, "Conn %d has %s circuit: circID %d "
-      "(other side %d), state %d (%s), born %ld:",
-      conn_array_index, type, this_circid, other_circid, circ->state,
-      circuit_state_to_string(circ->state),
+  tor_log(severity, LD_CIRC, "Conn %d has %s circuit: circID %u "
+      "(other side %u), state %d (%s), born %ld:",
+      conn_array_index, type, (unsigned)this_circid, (unsigned)other_circid,
+      circ->state, circuit_state_to_string(circ->state),
       (long)circ->timestamp_began.tv_sec);
   if (CIRCUIT_IS_ORIGIN(circ)) { /* circ starts at this node */
     circuit_log_path(severity, LD_CIRC, TO_ORIGIN_CIRCUIT(circ));
@@ -843,12 +843,12 @@ circuit_dump_chan_details(int severity,
                           circuit_t *circ,
                           channel_t *chan,
                           const char *type,
-                          int this_circid,
-                          int other_circid)
+                          circid_t this_circid,
+                          circid_t other_circid)
 {
-  tor_log(severity, LD_CIRC, "Conn %p has %s circuit: circID %d "
-      "(other side %d), state %d (%s), born %ld:",
-      chan, type, this_circid, other_circid, circ->state,
+  tor_log(severity, LD_CIRC, "Conn %p has %s circuit: circID %u "
+      "(other side %u), state %d (%s), born %ld:",
+      chan, type, (unsigned)this_circid, (unsigned)other_circid, circ->state,
       circuit_state_to_string(circ->state),
       (long)circ->timestamp_began.tv_sec);
   if (CIRCUIT_IS_ORIGIN(circ)) { /* circ starts at this node */
@@ -943,16 +943,16 @@ circuit_get_by_circid_channel_impl(circid_t circ_id, channel_t *chan)
   if (found && found->circuit) {
     log_debug(LD_CIRC,
               "circuit_get_by_circid_channel_impl() returning circuit %p for"
-              " circ_id %d, channel ID " U64_FORMAT " (%p)",
-              found->circuit, circ_id,
+              " circ_id %u, channel ID " U64_FORMAT " (%p)",
+              found->circuit, (unsigned)circ_id,
               U64_PRINTF_ARG(chan->global_identifier), chan);
     return found->circuit;
   }
 
   log_debug(LD_CIRC,
             "circuit_get_by_circid_channel_impl() found nothing for"
-            " circ_id %d, channel ID " U64_FORMAT " (%p)",
-            circ_id,
+            " circ_id %u, channel ID " U64_FORMAT " (%p)",
+            (unsigned)circ_id,
             U64_PRINTF_ARG(chan->global_identifier), chan);
 
   return NULL;
diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c
index dcc1901..545cfd0 100644
--- a/src/or/circuitmux.c
+++ b/src/or/circuitmux.c
@@ -425,9 +425,9 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
           } else {
             /* Complain and move on */
             log_warn(LD_CIRC,
-                     "Circuit %d/channel " U64_FORMAT " had direction == "
+                     "Circuit %u/channel " U64_FORMAT " had direction == "
                      "CELL_DIRECTION_IN, but isn't an or_circuit_t",
-                     to_remove->circ_id,
+                     (unsigned)to_remove->circ_id,
                      U64_PRINTF_ARG(to_remove->chan_id));
           }
 
@@ -449,16 +449,16 @@ circuitmux_detach_all_circuits(circuitmux_t *cmux)
         } else {
           /* Complain and move on */
           log_warn(LD_CIRC,
-                   "Couldn't find circuit %d (for channel " U64_FORMAT ")",
-                   to_remove->circ_id,
+                   "Couldn't find circuit %u (for channel " U64_FORMAT ")",
+                   (unsigned)to_remove->circ_id,
                    U64_PRINTF_ARG(to_remove->chan_id));
         }
       } else {
         /* Complain and move on */
         log_warn(LD_CIRC,
-                 "Couldn't find channel " U64_FORMAT " (for circuit id %d)",
+                 "Couldn't find channel " U64_FORMAT " (for circuit id %u)",
                  U64_PRINTF_ARG(to_remove->chan_id),
-                 to_remove->circ_id);
+                 (unsigned)to_remove->circ_id);
       }
 
       /* Assert that we don't have un-freed policy data for this circuit */
@@ -905,7 +905,7 @@ circuitmux_attach_circuit(circuitmux_t *cmux, circuit_t *circ,
     log_info(LD_CIRC,
              "Circuit %u on channel " U64_FORMAT " was already attached to "
              "cmux %p (trying to attach to %p)",
-             circ_id, U64_PRINTF_ARG(channel_id),
+             (unsigned)circ_id, U64_PRINTF_ARG(channel_id),
              ((direction == CELL_DIRECTION_OUT) ?
                 circ->n_mux : TO_OR_CIRCUIT(circ)->p_mux),
              cmux);
@@ -938,7 +938,7 @@ circuitmux_attach_circuit(circuitmux_t *cmux, circuit_t *circ,
      */
     log_debug(LD_CIRC,
              "Attaching circuit %u on channel " U64_FORMAT " to cmux %p",
-             circ_id, U64_PRINTF_ARG(channel_id), cmux);
+              (unsigned)circ_id, U64_PRINTF_ARG(channel_id), cmux);
 
     /*
      * Assert that the circuit doesn't already have a mux for this
@@ -1138,8 +1138,8 @@ circuitmux_make_circuit_active(circuitmux_t *cmux, circuit_t *circ,
   /* If we're already active, log a warning and finish */
   if (already_active) {
     log_warn(LD_CIRC,
-             "Circuit %d on channel " U64_FORMAT " was already active",
-             circ_id, U64_PRINTF_ARG(chan->global_identifier));
+             "Circuit %u on channel " U64_FORMAT " was already active",
+             (unsigned)circ_id, U64_PRINTF_ARG(chan->global_identifier));
     return;
   }
 
@@ -1236,7 +1236,7 @@ circuitmux_make_circuit_inactive(circuitmux_t *cmux, circuit_t *circ,
   if (already_inactive) {
     log_warn(LD_CIRC,
              "Circuit %d on channel " U64_FORMAT " was already inactive",
-             circ_id, U64_PRINTF_ARG(chan->global_identifier));
+             (unsigned)circ_id, U64_PRINTF_ARG(chan->global_identifier));
     return;
   }
 
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index c061203..51d8716 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -695,9 +695,9 @@ circuit_expire_building(void)
       case CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT:
       case CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED:
         /* If we have reached this line, we want to spare the circ for now. */
-        log_info(LD_CIRC,"Marking circ %d (state %d:%s, purpose %d) "
+        log_info(LD_CIRC,"Marking circ %u (state %d:%s, purpose %d) "
                  "as timed-out HS circ",
-                 victim->n_circ_id,
+                 (unsigned)victim->n_circ_id,
                  victim->state, circuit_state_to_string(victim->state),
                  victim->purpose);
         TO_ORIGIN_CIRCUIT(victim)->hs_circ_has_timed_out = 1;
@@ -713,9 +713,9 @@ circuit_expire_building(void)
     if (!(options->CloseHSServiceRendCircuitsImmediatelyOnTimeout) &&
         !(TO_ORIGIN_CIRCUIT(victim)->hs_circ_has_timed_out) &&
         victim->purpose == CIRCUIT_PURPOSE_S_CONNECT_REND) {
-      log_info(LD_CIRC,"Marking circ %d (state %d:%s, purpose %d) "
+      log_info(LD_CIRC,"Marking circ %u (state %d:%s, purpose %d) "
                "as timed-out HS circ; relaunching rendezvous attempt.",
-               victim->n_circ_id,
+               (unsigned)victim->n_circ_id,
                victim->state, circuit_state_to_string(victim->state),
                victim->purpose);
       TO_ORIGIN_CIRCUIT(victim)->hs_circ_has_timed_out = 1;
@@ -728,7 +728,7 @@ circuit_expire_building(void)
                "Abandoning circ %u %s:%d (state %d,%d:%s, purpose %d, "
                "len %d)", TO_ORIGIN_CIRCUIT(victim)->global_identifier,
                channel_get_canonical_remote_descr(victim->n_chan),
-               victim->n_circ_id,
+               (unsigned)victim->n_circ_id,
                TO_ORIGIN_CIRCUIT(victim)->has_opened,
                victim->state, circuit_state_to_string(victim->state),
                victim->purpose,
@@ -737,7 +737,8 @@ circuit_expire_building(void)
       log_info(LD_CIRC,
                "Abandoning circ %u %d (state %d,%d:%s, purpose %d, len %d)",
                TO_ORIGIN_CIRCUIT(victim)->global_identifier,
-               victim->n_circ_id, TO_ORIGIN_CIRCUIT(victim)->has_opened,
+               (unsigned)victim->n_circ_id,
+               TO_ORIGIN_CIRCUIT(victim)->has_opened,
                victim->state,
                circuit_state_to_string(victim->state), victim->purpose,
                TO_ORIGIN_CIRCUIT(victim)->build_state->desired_path_len);
@@ -1070,9 +1071,10 @@ circuit_expire_old_circuits_clientside(void)
         circ->timestamp_dirty + get_options()->MaxCircuitDirtiness <
           now.tv_sec &&
         !TO_ORIGIN_CIRCUIT(circ)->p_streams /* nothing attached */ ) {
-      log_debug(LD_CIRC, "Closing n_circ_id %d (dirty %ld sec ago, "
+      log_debug(LD_CIRC, "Closing n_circ_id %u (dirty %ld sec ago, "
                 "purpose %d)",
-                circ->n_circ_id, (long)(now.tv_sec - circ->timestamp_dirty),
+                (unsigned)circ->n_circ_id,
+                (long)(now.tv_sec - circ->timestamp_dirty),
                 circ->purpose);
       /* Don't do this magic for testing circuits. Their death is governed
        * by circuit_expire_building */
@@ -1153,8 +1155,8 @@ circuit_expire_old_circuits_serverside(time_t now)
         !or_circ->n_streams && !or_circ->resolving_streams &&
         or_circ->p_chan &&
         channel_when_last_xmit(or_circ->p_chan) <= cutoff) {
-      log_info(LD_CIRC, "Closing circ_id %d (empty %d secs ago)",
-               or_circ->p_circ_id,
+      log_info(LD_CIRC, "Closing circ_id %u (empty %d secs ago)",
+               (unsigned)or_circ->p_circ_id,
                (int)(now - channel_when_last_xmit(or_circ->p_chan)));
       circuit_mark_for_close(circ, END_CIRC_REASON_FINISHED);
     }
@@ -1896,8 +1898,8 @@ link_apconn_to_circ(entry_connection_t *apconn, origin_circuit_t *circ,
   const node_t *exitnode;
 
   /* add it into the linked list of streams on this circuit */
-  log_debug(LD_APP|LD_CIRC, "attaching new conn to circ. n_circ_id %d.",
-            circ->base_.n_circ_id);
+  log_debug(LD_APP|LD_CIRC, "attaching new conn to circ. n_circ_id %u.",
+            (unsigned)circ->base_.n_circ_id);
   /* reset it, so we can measure circ timeouts */
   ENTRY_TO_CONN(apconn)->timestamp_lastread = time(NULL);
   ENTRY_TO_EDGE_CONN(apconn)->next_stream = circ->p_streams;
@@ -2121,8 +2123,8 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
       return retval;
 
     log_debug(LD_APP|LD_CIRC,
-              "Attaching apconn to circ %d (stream %d sec old).",
-              circ->base_.n_circ_id, conn_age);
+              "Attaching apconn to circ %u (stream %d sec old).",
+              (unsigned)circ->base_.n_circ_id, conn_age);
     /* print the circ's path, so people can figure out which circs are
      * sucking. */
     circuit_log_path(LOG_INFO,LD_APP|LD_CIRC,circ);
@@ -2147,7 +2149,7 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
       log_info(LD_REND,
                "rend joined circ %d already here. attaching. "
                "(stream %d sec old)",
-               rendcirc->base_.n_circ_id, conn_age);
+               (unsigned)rendcirc->base_.n_circ_id, conn_age);
       /* Mark rendezvous circuits as 'newly dirty' every time you use
        * them, since the process of rebuilding a rendezvous circ is so
        * expensive. There is a tradeoff between linkability and
@@ -2168,9 +2170,9 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
     if (rendcirc && (rendcirc->base_.purpose ==
                      CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED)) {
       log_info(LD_REND,
-               "pending-join circ %d already here, with intro ack. "
+               "pending-join circ %u already here, with intro ack. "
                "Stalling. (stream %d sec old)",
-                rendcirc->base_.n_circ_id, conn_age);
+               (unsigned)rendcirc->base_.n_circ_id, conn_age);
       return 0;
     }
 
@@ -2182,10 +2184,10 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
     if (retval > 0) {
       /* one has already sent the intro. keep waiting. */
       tor_assert(introcirc);
-      log_info(LD_REND, "Intro circ %d present and awaiting ack (rend %d). "
+      log_info(LD_REND, "Intro circ %u present and awaiting ack (rend %u). "
                "Stalling. (stream %d sec old)",
-               introcirc->base_.n_circ_id,
-               rendcirc ? rendcirc->base_.n_circ_id : 0,
+               (unsigned)introcirc->base_.n_circ_id,
+               rendcirc ? (unsigned)rendcirc->base_.n_circ_id : 0,
                conn_age);
       return 0;
     }
@@ -2195,16 +2197,17 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
     if (rendcirc && introcirc &&
         rendcirc->base_.purpose == CIRCUIT_PURPOSE_C_REND_READY) {
       log_info(LD_REND,
-               "ready rend circ %d already here (no intro-ack yet on "
-               "intro %d). (stream %d sec old)",
-               rendcirc->base_.n_circ_id,
-               introcirc->base_.n_circ_id, conn_age);
+               "ready rend circ %u already here (no intro-ack yet on "
+               "intro %u). (stream %d sec old)",
+               (unsigned)rendcirc->base_.n_circ_id,
+               (unsigned)introcirc->base_.n_circ_id, conn_age);
 
       tor_assert(introcirc->base_.purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
       if (introcirc->base_.state == CIRCUIT_STATE_OPEN) {
-        log_info(LD_REND,"found open intro circ %d (rend %d); sending "
+        log_info(LD_REND,"found open intro circ %u (rend %u); sending "
                  "introduction. (stream %d sec old)",
-                 introcirc->base_.n_circ_id, rendcirc->base_.n_circ_id,
+                 (unsigned)introcirc->base_.n_circ_id,
+                 (unsigned)rendcirc->base_.n_circ_id,
                  conn_age);
         switch (rend_client_send_introduction(introcirc, rendcirc)) {
         case 0: /* success */
@@ -2228,10 +2231,10 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
       }
     }
 
-    log_info(LD_REND, "Intro (%d) and rend (%d) circs are not both ready. "
+    log_info(LD_REND, "Intro (%u) and rend (%u) circs are not both ready. "
              "Stalling conn. (%d sec old)",
-             introcirc ? introcirc->base_.n_circ_id : 0,
-             rendcirc ? rendcirc->base_.n_circ_id : 0, conn_age);
+             introcirc ? (unsigned)introcirc->base_.n_circ_id : 0,
+             rendcirc ? (unsigned)rendcirc->base_.n_circ_id : 0, conn_age);
     return 0;
   }
 }
diff --git a/src/or/command.c b/src/or/command.c
index dfe4f65..876ff52 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -16,7 +16,6 @@
  *   callbacks registered in command_setup_channel(),
  *   called when channels are created in circuitbuild.c
  */
-
 #include "or.h"
 #include "channel.h"
 #include "circuitbuild.h"
@@ -195,9 +194,9 @@ command_process_create_cell(cell_t *cell, channel_t *chan)
   tor_assert(chan);
 
   log_debug(LD_OR,
-            "Got a CREATE cell for circ_id %d on channel " U64_FORMAT
+            "Got a CREATE cell for circ_id %u on channel " U64_FORMAT
             " (%p)",
-            cell->circ_id,
+            (unsigned)cell->circ_id,
             U64_PRINTF_ARG(chan->global_identifier), chan);
 
   if (we_are_hibernating()) {
@@ -240,8 +239,8 @@ command_process_create_cell(cell_t *cell, channel_t *chan)
       (!id_is_high &&
        chan->circ_id_type == CIRC_ID_TYPE_LOWER)) {
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
-           "Received create cell with unexpected circ_id %d. Closing.",
-           cell->circ_id);
+           "Received create cell with unexpected circ_id %u. Closing.",
+           (unsigned)cell->circ_id);
     channel_send_destroy(cell->circ_id, chan,
                          END_CIRC_REASON_TORPROTOCOL);
     return;
@@ -250,9 +249,10 @@ command_process_create_cell(cell_t *cell, channel_t *chan)
   if (circuit_id_in_use_on_channel(cell->circ_id, chan)) {
     const node_t *node = node_get_by_id(chan->identity_digest);
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
-           "Received CREATE cell (circID %d) for known circ. "
+           "Received CREATE cell (circID %u) for known circ. "
            "Dropping (age %d).",
-           cell->circ_id, (int)(time(NULL) - channel_when_created(chan)));
+           (unsigned)cell->circ_id,
+           (int)(time(NULL) - channel_when_created(chan)));
     if (node) {
       char *p = esc_for_log(node_get_platform(node));
       log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
@@ -341,8 +341,8 @@ command_process_created_cell(cell_t *cell, channel_t *chan)
 
   if (!circ) {
     log_info(LD_OR,
-             "(circID %d) unknown circ (probably got a destroy earlier). "
-             "Dropping.", cell->circ_id);
+             "(circID %u) unknown circ (probably got a destroy earlier). "
+             "Dropping.", (unsigned)cell->circ_id);
     return;
   }
 
@@ -412,8 +412,9 @@ command_process_relay_cell(cell_t *cell, channel_t *chan)
 
   if (!circ) {
     log_debug(LD_OR,
-              "unknown circuit %d on connection from %s. Dropping.",
-              cell->circ_id, channel_get_canonical_remote_descr(chan));
+              "unknown circuit %u on connection from %s. Dropping.",
+              (unsigned)cell->circ_id,
+              channel_get_canonical_remote_descr(chan));
     return;
   }
 
@@ -447,9 +448,9 @@ command_process_relay_cell(cell_t *cell, channel_t *chan)
       or_circuit_t *or_circ = TO_OR_CIRCUIT(circ);
       if (or_circ->remaining_relay_early_cells == 0) {
         log_fn(LOG_PROTOCOL_WARN, LD_OR,
-               "Received too many RELAY_EARLY cells on circ %d from %s."
+               "Received too many RELAY_EARLY cells on circ %u from %s."
                "  Closing circuit.",
-               cell->circ_id,
+               (unsigned)cell->circ_id,
                safe_str(channel_get_canonical_remote_descr(chan)));
         circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
         return;
@@ -487,11 +488,12 @@ command_process_destroy_cell(cell_t *cell, channel_t *chan)
 
   circ = circuit_get_by_circid_channel(cell->circ_id, chan);
   if (!circ) {
-    log_info(LD_OR,"unknown circuit %d on connection from %s. Dropping.",
-             cell->circ_id, channel_get_canonical_remote_descr(chan));
+    log_info(LD_OR,"unknown circuit %u on connection from %s. Dropping.",
+             (unsigned)cell->circ_id,
+             channel_get_canonical_remote_descr(chan));
     return;
   }
-  log_debug(LD_OR,"Received for circID %d.",cell->circ_id);
+  log_debug(LD_OR,"Received for circID %u.",(unsigned)cell->circ_id);
 
   reason = (uint8_t)cell->payload[0];
 
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index fcbcb95..84d5565 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -218,8 +218,8 @@ int
 connection_edge_destroy(circid_t circ_id, edge_connection_t *conn)
 {
   if (!conn->base_.marked_for_close) {
-    log_info(LD_EDGE,
-             "CircID %d: At an edge. Marking connection for close.", circ_id);
+    log_info(LD_EDGE, "CircID %u: At an edge. Marking connection for close.",
+             (unsigned) circ_id);
     if (conn->base_.type == CONN_TYPE_AP) {
       entry_connection_t *entry_conn = EDGE_TO_ENTRY_CONN(conn);
       connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_DESTROY);
@@ -1847,8 +1847,8 @@ connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
   edge_conn->deliver_window = STREAMWINDOW_START;
   base_conn->state = AP_CONN_STATE_CONNECT_WAIT;
   log_info(LD_APP,"Address/port sent, ap socket "TOR_SOCKET_T_FORMAT
-           ", n_circ_id %d",
-           base_conn->s, circ->base_.n_circ_id);
+           ", n_circ_id %u",
+           base_conn->s, (unsigned)circ->base_.n_circ_id);
   control_event_stream_status(ap_conn, STREAM_EVENT_SENT_CONNECT, 0);
 
   /* If there's queued-up data, send it now */
@@ -1949,8 +1949,8 @@ connection_ap_handshake_send_resolve(entry_connection_t *ap_conn)
   base_conn->address = tor_strdup("(Tor_internal)");
   base_conn->state = AP_CONN_STATE_RESOLVE_WAIT;
   log_info(LD_APP,"Address sent for resolve, ap socket "TOR_SOCKET_T_FORMAT
-           ", n_circ_id %d",
-           base_conn->s, circ->base_.n_circ_id);
+           ", n_circ_id %u",
+           base_conn->s, (unsigned)circ->base_.n_circ_id);
   control_event_stream_status(ap_conn, STREAM_EVENT_NEW, 0);
   control_event_stream_status(ap_conn, STREAM_EVENT_SENT_RESOLVE, 0);
   return 0;
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index c4415c5..3616363 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -9,7 +9,6 @@
  * \brief Functions to handle OR connections, TLS handshaking, and
  * cells on the network.
  **/
-
 #include "or.h"
 #include "buffers.h"
 /*
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index af5f91a..38c6613 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -11,7 +11,6 @@
  *
  * Right now, we only use this for processing onionskins.
  **/
-
 #include "or.h"
 #include "buffers.h"
 #include "channel.h"
@@ -341,8 +340,8 @@ connection_cpu_process_inbuf(connection_t *conn)
     circ = NULL;
     log_debug(LD_OR,
               "Unpacking cpuworker reply, chan_id is " U64_FORMAT
-              ", circ_id is %d",
-              U64_PRINTF_ARG(chan_id), circ_id);
+              ", circ_id is %u",
+              U64_PRINTF_ARG(chan_id), (unsigned)circ_id);
     p_chan = channel_find_by_global_id(chan_id);
 
     if (p_chan)
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 61e3b91..7115bf2 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -111,14 +111,14 @@ rend_client_reextend_intro_circuit(origin_circuit_t *circ)
   // XXX: should we not re-extend if hs_circ_has_timed_out?
   if (circ->remaining_relay_early_cells) {
     log_info(LD_REND,
-             "Re-extending circ %d, this time to %s.",
-             circ->base_.n_circ_id,
+             "Re-extending circ %u, this time to %s.",
+             (unsigned)circ->base_.n_circ_id,
              safe_str_client(extend_info_describe(extend_info)));
     result = circuit_extend_to_new_exit(circ, extend_info);
   } else {
     log_info(LD_REND,
-             "Closing intro circ %d (out of RELAY_EARLY cells).",
-             circ->base_.n_circ_id);
+             "Closing intro circ %u (out of RELAY_EARLY cells).",
+             (unsigned)circ->base_.n_circ_id);
     circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_FINISHED);
     /* connection_ap_handshake_attach_circuit will launch a new intro circ. */
     result = 0;
@@ -386,8 +386,8 @@ rend_client_introduction_acked(origin_circuit_t *circ,
 
   if (circ->base_.purpose != CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) {
     log_warn(LD_PROTOCOL,
-             "Received REND_INTRODUCE_ACK on unexpected circuit %d.",
-             circ->base_.n_circ_id);
+             "Received REND_INTRODUCE_ACK on unexpected circuit %u.",
+             (unsigned)circ->base_.n_circ_id);
     circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_TORPROTOCOL);
     return -1;
   }
diff --git a/src/or/rendmid.c b/src/or/rendmid.c
index 1046ce3..1bd11f6 100644
--- a/src/or/rendmid.c
+++ b/src/or/rendmid.c
@@ -32,8 +32,8 @@ rend_mid_establish_intro(or_circuit_t *circ, const uint8_t *request,
   int reason = END_CIRC_REASON_INTERNAL;
 
   log_info(LD_REND,
-           "Received an ESTABLISH_INTRO request on circuit %d",
-           circ->p_circ_id);
+           "Received an ESTABLISH_INTRO request on circuit %u",
+           (unsigned) circ->p_circ_id);
 
   if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
@@ -114,8 +114,8 @@ rend_mid_establish_intro(or_circuit_t *circ, const uint8_t *request,
   memcpy(circ->rend_token, pk_digest, DIGEST_LEN);
 
   log_info(LD_REND,
-           "Established introduction point on circuit %d for service %s",
-           circ->p_circ_id, safe_str(serviceid));
+           "Established introduction point on circuit %u for service %s",
+           (unsigned) circ->p_circ_id, safe_str(serviceid));
 
   return 0;
  truncated:
@@ -139,13 +139,13 @@ rend_mid_introduce(or_circuit_t *circ, const uint8_t *request,
   char serviceid[REND_SERVICE_ID_LEN_BASE32+1];
   char nak_body[1];
 
-  log_info(LD_REND, "Received an INTRODUCE1 request on circuit %d",
-           circ->p_circ_id);
+  log_info(LD_REND, "Received an INTRODUCE1 request on circuit %u",
+           (unsigned)circ->p_circ_id);
 
   if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
     log_warn(LD_PROTOCOL,
-             "Rejecting INTRODUCE1 on non-OR or non-edge circuit %d.",
-             circ->p_circ_id);
+             "Rejecting INTRODUCE1 on non-OR or non-edge circuit %u.",
+             (unsigned)circ->p_circ_id);
     goto err;
   }
 
@@ -155,9 +155,9 @@ rend_mid_introduce(or_circuit_t *circ, const uint8_t *request,
    */
   if (request_len < (DIGEST_LEN+(MAX_NICKNAME_LEN+1)+REND_COOKIE_LEN+
                      DH_KEY_LEN+CIPHER_KEY_LEN+PKCS1_OAEP_PADDING_OVERHEAD)) {
-    log_warn(LD_PROTOCOL, "Impossibly short INTRODUCE1 cell on circuit %d; "
+    log_warn(LD_PROTOCOL, "Impossibly short INTRODUCE1 cell on circuit %u; "
              "responding with nack.",
-             circ->p_circ_id);
+             (unsigned)circ->p_circ_id);
     goto err;
   }
 
@@ -168,17 +168,17 @@ rend_mid_introduce(or_circuit_t *circ, const uint8_t *request,
   intro_circ = circuit_get_intro_point((char*)request);
   if (!intro_circ) {
     log_info(LD_REND,
-             "No intro circ found for INTRODUCE1 cell (%s) from circuit %d; "
+             "No intro circ found for INTRODUCE1 cell (%s) from circuit %u; "
              "responding with nack.",
-             safe_str(serviceid), circ->p_circ_id);
+             safe_str(serviceid), (unsigned)circ->p_circ_id);
     goto err;
   }
 
   log_info(LD_REND,
            "Sending introduction request for service %s "
-           "from circ %d to circ %d",
-           safe_str(serviceid), circ->p_circ_id,
-           intro_circ->p_circ_id);
+           "from circ %u to circ %u",
+           safe_str(serviceid), (unsigned)circ->p_circ_id,
+           (unsigned)intro_circ->p_circ_id);
 
   /* Great.  Now we just relay the cell down the circuit. */
   if (relay_send_command_from_edge(0, TO_CIRCUIT(intro_circ),
@@ -221,8 +221,8 @@ rend_mid_establish_rendezvous(or_circuit_t *circ, const uint8_t *request,
   char hexid[9];
   int reason = END_CIRC_REASON_TORPROTOCOL;
 
-  log_info(LD_REND, "Received an ESTABLISH_RENDEZVOUS request on circuit %d",
-           circ->p_circ_id);
+  log_info(LD_REND, "Received an ESTABLISH_RENDEZVOUS request on circuit %u",
+           (unsigned)circ->p_circ_id);
 
   if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
     log_warn(LD_PROTOCOL,
@@ -256,8 +256,8 @@ rend_mid_establish_rendezvous(or_circuit_t *circ, const uint8_t *request,
   base16_encode(hexid,9,(char*)request,4);
 
   log_info(LD_REND,
-           "Established rendezvous point on circuit %d for cookie %s",
-           circ->p_circ_id, hexid);
+           "Established rendezvous point on circuit %u for cookie %s",
+           (unsigned)circ->p_circ_id, hexid);
 
   return 0;
  err:
@@ -279,16 +279,16 @@ rend_mid_rendezvous(or_circuit_t *circ, const uint8_t *request,
 
   if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
     log_info(LD_REND,
-             "Tried to complete rendezvous on non-OR or non-edge circuit %d.",
-             circ->p_circ_id);
+             "Tried to complete rendezvous on non-OR or non-edge circuit %u.",
+             (unsigned)circ->p_circ_id);
     reason = END_CIRC_REASON_TORPROTOCOL;
     goto err;
   }
 
   if (request_len != REND_COOKIE_LEN+DH_KEY_LEN+DIGEST_LEN) {
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
-         "Rejecting RENDEZVOUS1 cell with bad length (%d) on circuit %d.",
-         (int)request_len, circ->p_circ_id);
+         "Rejecting RENDEZVOUS1 cell with bad length (%d) on circuit %u.",
+         (int)request_len, (unsigned)circ->p_circ_id);
     reason = END_CIRC_REASON_TORPROTOCOL;
     goto err;
   }
@@ -296,8 +296,8 @@ rend_mid_rendezvous(or_circuit_t *circ, const uint8_t *request,
   base16_encode(hexid, sizeof(hexid), (const char*)request, 4);
 
   log_info(LD_REND,
-           "Got request for rendezvous from circuit %d to cookie %s.",
-           circ->p_circ_id, hexid);
+           "Got request for rendezvous from circuit %u to cookie %s.",
+           (unsigned)circ->p_circ_id, hexid);
 
   rend_circ = circuit_get_rendezvous((char*)request);
   if (!rend_circ) {
@@ -314,15 +314,15 @@ rend_mid_rendezvous(or_circuit_t *circ, const uint8_t *request,
                                    (char*)(request+REND_COOKIE_LEN),
                                    request_len-REND_COOKIE_LEN, NULL)) {
     log_warn(LD_GENERAL,
-             "Unable to send RENDEZVOUS2 cell to client on circuit %d.",
-             rend_circ->p_circ_id);
+             "Unable to send RENDEZVOUS2 cell to client on circuit %u.",
+             (unsigned)rend_circ->p_circ_id);
     goto err;
   }
 
   /* Join the circuits. */
   log_info(LD_REND,
-           "Completing rendezvous: circuit %d joins circuit %d (cookie %s)",
-           circ->p_circ_id, rend_circ->p_circ_id, hexid);
+           "Completing rendezvous: circuit %u joins circuit %u (cookie %s)",
+           (unsigned)circ->p_circ_id, (unsigned)rend_circ->p_circ_id, hexid);
 
   circuit_change_purpose(TO_CIRCUIT(circ), CIRCUIT_PURPOSE_REND_ESTABLISHED);
   circuit_change_purpose(TO_CIRCUIT(rend_circ),
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index a066e02..a8f63dd 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -1126,8 +1126,8 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   /* Do some initial validation and logging before we parse the cell */
   if (circuit->base_.purpose != CIRCUIT_PURPOSE_S_INTRO) {
     log_warn(LD_PROTOCOL,
-             "Got an INTRODUCE2 over a non-introduction circuit %d.",
-             circuit->base_.n_circ_id);
+             "Got an INTRODUCE2 over a non-introduction circuit %u.",
+             (unsigned) circuit->base_.n_circ_id);
     goto err;
   }
 
@@ -1161,8 +1161,8 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
     goto err;
   }
 
-  log_info(LD_REND, "Received INTRODUCE2 cell for service %s on circ %d.",
-           escaped(serviceid), circuit->base_.n_circ_id);
+  log_info(LD_REND, "Received INTRODUCE2 cell for service %s on circ %u.",
+           escaped(serviceid), (unsigned)circuit->base_.n_circ_id);
 
   /* use intro key instead of service key. */
   intro_key = circuit->intro_key;
@@ -1177,7 +1177,8 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (!parsed_req) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
+    log_info(LD_REND, "%s on circ %u.", err_msg,
+             (unsigned)circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
 
@@ -1187,7 +1188,8 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (result < 0) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
+    log_info(LD_REND, "%s on circ %u.", err_msg,
+             (unsigned)circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
 
@@ -1223,7 +1225,8 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (result < 0) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
+    log_info(LD_REND, "%s on circ %u.", err_msg,
+             (unsigned)circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
 
@@ -1233,7 +1236,8 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (result < 0) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
+    log_info(LD_REND, "%s on circ %u.", err_msg,
+             (unsigned)circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
 
@@ -1243,7 +1247,8 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (result < 0) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
+    log_info(LD_REND, "%s on circ %u.", err_msg,
+             (unsigned)circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
   stage_descr = NULL;
@@ -1393,7 +1398,8 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
     }
   }
 
-  log_warn(LD_REND, "%s on circ %d", err_msg, circuit->base_.n_circ_id);
+  log_warn(LD_REND, "%s on circ %u", err_msg,
+           (unsigned)circuit->base_.n_circ_id);
  err:
   status = -1;
   if (dh) crypto_dh_free(dh);
@@ -2417,8 +2423,8 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
   service = rend_service_get_by_pk_digest(
                 circuit->rend_data->rend_pk_digest);
   if (!service) {
-    log_warn(LD_REND, "Unrecognized service ID %s on introduction circuit %d.",
-             serviceid, circuit->base_.n_circ_id);
+    log_warn(LD_REND, "Unrecognized service ID %s on introduction circuit %u.",
+             serviceid, (unsigned)circuit->base_.n_circ_id);
     reason = END_CIRC_REASON_NOSUCHSERVICE;
     goto err;
   }
@@ -2461,8 +2467,8 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
   }
 
   log_info(LD_REND,
-           "Established circuit %d as introduction point for service %s",
-           circuit->base_.n_circ_id, serviceid);
+           "Established circuit %u as introduction point for service %s",
+           (unsigned)circuit->base_.n_circ_id, serviceid);
 
   /* Use the intro key instead of the service key in ESTABLISH_INTRO. */
   intro_key = circuit->intro_key;
@@ -2496,8 +2502,8 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
                                    RELAY_COMMAND_ESTABLISH_INTRO,
                                    buf, len, circuit->cpath->prev)<0) {
     log_info(LD_GENERAL,
-             "Couldn't send introduction request for service %s on circuit %d",
-             serviceid, circuit->base_.n_circ_id);
+             "Couldn't send introduction request for service %s on circuit %u",
+             serviceid, (unsigned)circuit->base_.n_circ_id);
     reason = END_CIRC_REASON_INTERNAL;
     goto err;
   }
@@ -2539,8 +2545,8 @@ rend_service_intro_established(origin_circuit_t *circuit,
   service = rend_service_get_by_pk_digest(
                 circuit->rend_data->rend_pk_digest);
   if (!service) {
-    log_warn(LD_REND, "Unknown service on introduction circuit %d.",
-             circuit->base_.n_circ_id);
+    log_warn(LD_REND, "Unknown service on introduction circuit %u.",
+             (unsigned)circuit->base_.n_circ_id);
     goto err;
   }
   service->desc_is_dirty = time(NULL);
@@ -2549,8 +2555,8 @@ rend_service_intro_established(origin_circuit_t *circuit,
   base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32 + 1,
                 circuit->rend_data->rend_pk_digest, REND_SERVICE_ID_LEN);
   log_info(LD_REND,
-           "Received INTRO_ESTABLISHED cell on circuit %d for service %s",
-           circuit->base_.n_circ_id, serviceid);
+           "Received INTRO_ESTABLISHED cell on circuit %u for service %s",
+           (unsigned)circuit->base_.n_circ_id, serviceid);
 
   /* Getting a valid INTRODUCE_ESTABLISHED means we've successfully
    * used the circ */
@@ -2597,9 +2603,9 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit)
                 circuit->rend_data->rend_pk_digest, REND_SERVICE_ID_LEN);
 
   log_info(LD_REND,
-           "Done building circuit %d to rendezvous with "
+           "Done building circuit %u to rendezvous with "
            "cookie %s for service %s",
-           circuit->base_.n_circ_id, hexcookie, serviceid);
+           (unsigned)circuit->base_.n_circ_id, hexcookie, serviceid);
 
   /* Clear the 'in-progress HS circ has timed out' flag for
    * consistency with what happens on the client side; this line has
@@ -3339,8 +3345,8 @@ rend_service_set_connection_addr_port(edge_connection_t *conn,
                 circ->rend_data->rend_pk_digest);
   if (!service) {
     log_warn(LD_REND, "Couldn't find any service associated with pk %s on "
-             "rendezvous circuit %d; closing.",
-             serviceid, circ->base_.n_circ_id);
+             "rendezvous circuit %u; closing.",
+             serviceid, (unsigned)circ->base_.n_circ_id);
     return -1;
   }
   matching_ports = smartlist_new();



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits