[or-cvs] No longer permit create cells to have the wrong circ_id_typ...

arma at seul.org arma at seul.org
Tue Jul 4 03:27:11 UTC 2006


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

Modified Files:
	command.c 
Log Message:
No longer permit create cells to have the wrong circ_id_type. No
running Tors should still have this bug.


Index: command.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/command.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -p -d -r1.110 -r1.111
--- command.c	5 Mar 2006 09:50:25 -0000	1.110
+++ command.c	4 Jul 2006 03:27:09 -0000	1.111
@@ -173,23 +173,17 @@ command_process_create_cell(cell_t *cell
     return;
   }
 
-  /* If the high bit of the circuit ID is not as expected, then switch
-   * which half of the space we'll use for our own CREATE cells.
-   *
-   * This can happen because Tor 0.0.9pre5 and earlier decide which
-   * half to use based on nickname, and we now use identity keys.
-   */
+  /* If the high bit of the circuit ID is not as expected, close the
+   * circ. */
   id_is_high = cell->circ_id & (1<<15);
-  if (id_is_high && conn->circ_id_type == CIRC_ID_TYPE_HIGHER) {
-    log_info(LD_OR, "Got a high circuit ID from %s (%d); switching to "
-             "low circuit IDs.",
-             conn->nickname ? conn->nickname : "client", conn->s);
-    conn->circ_id_type = CIRC_ID_TYPE_LOWER;
-  } else if (!id_is_high && conn->circ_id_type == CIRC_ID_TYPE_LOWER) {
-    log_info(LD_OR, "Got a low circuit ID from %s (%d); switching to "
-             "high circuit IDs.",
-             conn->nickname ? conn->nickname : "client", conn->s);
-    conn->circ_id_type = CIRC_ID_TYPE_HIGHER;
+  if ((id_is_high && conn->circ_id_type == CIRC_ID_TYPE_HIGHER) ||
+      (!id_is_high && conn->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);
+    connection_or_send_destroy(cell->circ_id, conn,
+                               END_CIRC_REASON_TORPROTOCOL);
+    return;
   }
 
   circ = circuit_get_by_circid_orconn(cell->circ_id, conn);
@@ -197,7 +191,7 @@ command_process_create_cell(cell_t *cell
   if (circ) {
     routerinfo_t *router = router_get_by_digest(conn->identity_digest);
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
-           "received CREATE cell (circID %d) for known circ. "
+           "Received CREATE cell (circID %d) for known circ. "
            "Dropping (age %d).",
            cell->circ_id, (int)(time(NULL) - conn->timestamp_created));
     if (router)
@@ -214,7 +208,7 @@ command_process_create_cell(cell_t *cell
     circ->onionskin = tor_malloc(ONIONSKIN_CHALLENGE_LEN);
     memcpy(circ->onionskin, cell->payload, ONIONSKIN_CHALLENGE_LEN);
 
-    /* hand it off to the cpuworkers, and then return */
+    /* hand it off to the cpuworkers, and then return. */
     if (assign_to_cpuworker(NULL, CPUWORKER_TASK_ONION, circ) < 0) {
       log_warn(LD_GENERAL,"Failed to hand off onionskin. Closing.");
       circuit_mark_for_close(circ, END_CIRC_REASON_INTERNAL);
@@ -223,7 +217,7 @@ command_process_create_cell(cell_t *cell
     log_debug(LD_OR,"success: handed off onionskin.");
   } else {
     /* This is a CREATE_FAST cell; we can handle it immediately without using
-     * a CPU worker.*/
+     * a CPU worker. */
     char keys[CPATH_KEY_MATERIAL_LEN];
     char reply[DIGEST_LEN*2];
     tor_assert(cell->command == CELL_CREATE_FAST);



More information about the tor-commits mailing list