]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Reorder rend_mid_rendezvous() to do protocol violation checks on top.
authorGeorge Kadianakis <desnacked@riseup.net>
Mon, 7 May 2012 15:05:54 +0000 (18:05 +0300)
committerGeorge Kadianakis <desnacked@riseup.net>
Mon, 7 May 2012 15:05:54 +0000 (18:05 +0300)
changes/bug5645 [new file with mode: 0644]
src/or/rendmid.c

diff --git a/changes/bug5645 b/changes/bug5645
new file mode 100644 (file)
index 0000000..0abd3b1
--- /dev/null
@@ -0,0 +1,5 @@
+  o Code refactoring:
+    - Defensively refactor rend_mid_rendezvous() so that protocol
+      violations and length checks happen in the beginning. Fixes bug
+      5645.
+
index 2742c351b3a7f418479a7a53ab59e5ac443dca63..391eab7f8284c552fc7e3f4f269da9624412f8d4 100644 (file)
@@ -276,13 +276,6 @@ rend_mid_rendezvous(or_circuit_t *circ, const uint8_t *request,
   or_circuit_t *rend_circ;
   char hexid[9];
   int reason = END_CIRC_REASON_INTERNAL;
-  base16_encode(hexid,9,(char*)request,request_len<4?request_len:4);
-
-  if (request_len>=4) {
-    log_info(LD_REND,
-             "Got request for rendezvous from circuit %d to cookie %s.",
-             circ->p_circ_id, hexid);
-  }
 
   if (circ->_base.purpose != CIRCUIT_PURPOSE_OR || circ->_base.n_conn) {
     log_info(LD_REND,
@@ -300,6 +293,12 @@ rend_mid_rendezvous(or_circuit_t *circ, const uint8_t *request,
     goto err;
   }
 
+  base16_encode(hexid, 9, (char*)request, 4);
+
+  log_info(LD_REND,
+           "Got request for rendezvous from circuit %d to cookie %s.",
+           circ->p_circ_id, hexid);
+
   rend_circ = circuit_get_rendezvous((char*)request);
   if (!rend_circ) {
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,