diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-12-06 00:21:24 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-01-03 11:29:47 -0500 |
commit | 5c68a1efaa9511baf2a2af0a49946e0a2de9e246 (patch) | |
tree | 2412460c251075f029c0d878dcf87bc2e97c3a15 /src/or/circuitbuild.c | |
parent | 1ed4786dba8912ab7a6eb16adf7554cf9a5c1ed1 (diff) | |
download | tor-5c68a1efaa9511baf2a2af0a49946e0a2de9e246.tar.gz tor-5c68a1efaa9511baf2a2af0a49946e0a2de9e246.zip |
Don't check create cells too much when we're relaying them
We want to sanity-check our own create cells carefully, and other
people's loosely.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r-- | src/or/circuitbuild.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 43ad9f4235..b7ab47f559 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -55,7 +55,8 @@ static channel_t * channel_connect_for_circuit(const tor_addr_t *addr, uint16_t port, const char *id_digest); static int circuit_deliver_create_cell(circuit_t *circ, - const create_cell_t *create_cell); + const create_cell_t *create_cell, + int relayed); static int onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit); static crypt_path_t *onion_next_hop_in_cpath(crypt_path_t *cpath); static int onion_extend_cpath(origin_circuit_t *circ); @@ -474,7 +475,7 @@ circuit_n_chan_done(channel_t *chan, int status) } else { /* pull the create cell out of circ->n_chan_create_cell, and send it */ tor_assert(circ->n_chan_create_cell); - if (circuit_deliver_create_cell(circ, circ->n_chan_create_cell)<0) { + if (circuit_deliver_create_cell(circ, circ->n_chan_create_cell, 1)<0) { circuit_mark_for_close(circ, END_CIRC_REASON_RESOURCELIMIT); continue; } @@ -491,14 +492,16 @@ circuit_n_chan_done(channel_t *chan, int status) * for the outgoing * circuit <b>circ</b>, and deliver a cell of type <b>cell_type</b> * (either CELL_CREATE or CELL_CREATE_FAST) with payload <b>payload</b> - * to this circuit. DOCDOC payload_len + * to this circuit. DOCDOC new arguments * Return -1 if we failed to find a suitable circid, else return 0. */ static int -circuit_deliver_create_cell(circuit_t *circ, const create_cell_t *create_cell) +circuit_deliver_create_cell(circuit_t *circ, const create_cell_t *create_cell, + int relayed) { cell_t cell; circid_t id; + int r; tor_assert(circ); tor_assert(circ->n_chan); @@ -516,7 +519,9 @@ circuit_deliver_create_cell(circuit_t *circ, const create_cell_t *create_cell) circuit_set_n_circid_chan(circ, id, circ->n_chan); memset(&cell, 0, sizeof(cell_t)); - if (create_cell_format(&cell, create_cell) < 0) { + r = relayed ? create_cell_format_relayed(&cell, create_cell) + : create_cell_format(&cell, create_cell); + if (r < 0) { log_warn(LD_CIRC,"Couldn't format create cell"); return -1; } @@ -657,7 +662,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ) } cc.handshake_len = len; - if (circuit_deliver_create_cell(TO_CIRCUIT(circ), &cc) < 0) + if (circuit_deliver_create_cell(TO_CIRCUIT(circ), &cc, 0) < 0) return - END_CIRC_REASON_RESOURCELIMIT; circ->cpath->state = CPATH_STATE_AWAITING_KEYS; @@ -901,8 +906,6 @@ circuit_extend(cell_t *cell, circuit_t *circ) &ec.orport_ipv4.addr, ec.orport_ipv4.port); - /* XXXX Make sure we can eventually deliver create cell with weird - * content */ circ->n_chan_create_cell = tor_memdup(&ec.create_cell, sizeof(ec.create_cell)); @@ -933,7 +936,7 @@ circuit_extend(cell_t *cell, circuit_t *circ) "n_chan is %s", channel_get_canonical_remote_descr(n_chan)); - if (circuit_deliver_create_cell(circ, &ec.create_cell) < 0) + if (circuit_deliver_create_cell(circ, &ec.create_cell, 1) < 0) return -1; return 0; } |