Browse Source

pass the reason from the truncated cell to the controller

(rather than just always declaring that the reason is
END_CIRC_REASON_OR_CONN_CLOSED)

resolves bug 7039.
Roger Dingledine 11 years ago
parent
commit
10b43f4c46
4 changed files with 13 additions and 4 deletions
  1. 7 0
      changes/bug7039
  2. 2 2
      src/or/circuitbuild.c
  3. 2 1
      src/or/circuitbuild.h
  4. 2 1
      src/or/relay.c

+ 7 - 0
changes/bug7039

@@ -0,0 +1,7 @@
+  o Minor bugfixes:
+    - When a Tor client gets a "truncated" relay cell, the first byte of
+      its payload specifies why the circuit was truncated. We were
+      ignoring this 'reason' byte when tearing down the circuit, resulting
+      in the controller not being told why the circuit closed. Now we
+      pass the reason from the truncated cell to the controller. Bugfix
+      on 0.1.2.3-alpha; fixes bug 7039.

+ 2 - 2
src/or/circuitbuild.c

@@ -2999,7 +2999,7 @@ circuit_finish_handshake(origin_circuit_t *circ, uint8_t reply_type,
  * just give up: for circ to close, and return 0.
  */
 int
-circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer)
+circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer, int reason)
 {
 //  crypt_path_t *victim;
 //  connection_t *stream;
@@ -3012,7 +3012,7 @@ circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer)
    *     just give up.
    */
   circuit_mark_for_close(TO_CIRCUIT(circ),
-          END_CIRC_REASON_FLAG_REMOTE|END_CIRC_REASON_OR_CONN_CLOSED);
+          END_CIRC_REASON_FLAG_REMOTE|reason);
   return 0;
 
 #if 0

+ 2 - 1
src/or/circuitbuild.h

@@ -32,7 +32,8 @@ int circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
                               int reverse);
 int circuit_finish_handshake(origin_circuit_t *circ, uint8_t cell_type,
                              const uint8_t *reply);
-int circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer);
+int circuit_truncated(origin_circuit_t *circ, crypt_path_t *layer,
+                      int reason);
 int onionskin_answer(or_circuit_t *circ, uint8_t cell_type,
                      const char *payload, const char *keys);
 int circuit_all_predicted_ports_handled(time_t now, int *need_uptime,

+ 2 - 1
src/or/relay.c

@@ -1251,7 +1251,8 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
                "'truncated' unsupported at non-origin. Dropping.");
         return 0;
       }
-      circuit_truncated(TO_ORIGIN_CIRCUIT(circ), layer_hint);
+      circuit_truncated(TO_ORIGIN_CIRCUIT(circ), layer_hint,
+                        get_uint8(cell->payload + RELAY_HEADER_SIZE));
       return 0;
     case RELAY_COMMAND_CONNECTED:
       if (conn) {