Merge remote-tracking branch 'dgoulet/bug20376_030_01'

This commit is contained in:
Nick Mathewson 2016-11-03 14:35:03 -04:00
commit 40487b0141
3 changed files with 15 additions and 17 deletions

View File

@ -610,14 +610,13 @@ relay_send_command_from_edge_(streamid_t stream_id, circuit_t *circ,
memset(&cell, 0, sizeof(cell_t)); memset(&cell, 0, sizeof(cell_t));
cell.command = CELL_RELAY; cell.command = CELL_RELAY;
if (cpath_layer) { if (CIRCUIT_IS_ORIGIN(circ)) {
tor_assert(cpath_layer);
cell.circ_id = circ->n_circ_id; cell.circ_id = circ->n_circ_id;
cell_direction = CELL_DIRECTION_OUT; cell_direction = CELL_DIRECTION_OUT;
} else if (! CIRCUIT_IS_ORIGIN(circ)) { } else {
cell.circ_id = TO_OR_CIRCUIT(circ)->p_circ_id; cell.circ_id = TO_OR_CIRCUIT(circ)->p_circ_id;
cell_direction = CELL_DIRECTION_IN; cell_direction = CELL_DIRECTION_IN;
} else {
return -1;
} }
memset(&rh, 0, sizeof(rh)); memset(&rh, 0, sizeof(rh));

View File

@ -106,7 +106,7 @@ rend_mid_establish_intro(or_circuit_t *circ, const uint8_t *request,
RELAY_COMMAND_INTRO_ESTABLISHED, RELAY_COMMAND_INTRO_ESTABLISHED,
"", 0, NULL)<0) { "", 0, NULL)<0) {
log_info(LD_GENERAL, "Couldn't send INTRO_ESTABLISHED cell."); log_info(LD_GENERAL, "Couldn't send INTRO_ESTABLISHED cell.");
goto err; goto err_no_close;
} }
/* Now, set up this circuit. */ /* Now, set up this circuit. */
@ -122,8 +122,9 @@ rend_mid_establish_intro(or_circuit_t *circ, const uint8_t *request,
log_warn(LD_PROTOCOL, "Rejecting truncated ESTABLISH_INTRO cell."); log_warn(LD_PROTOCOL, "Rejecting truncated ESTABLISH_INTRO cell.");
reason = END_CIRC_REASON_TORPROTOCOL; reason = END_CIRC_REASON_TORPROTOCOL;
err: err:
if (pk) crypto_pk_free(pk);
circuit_mark_for_close(TO_CIRCUIT(circ), reason); circuit_mark_for_close(TO_CIRCUIT(circ), reason);
err_no_close:
if (pk) crypto_pk_free(pk);
return -1; return -1;
} }
@ -201,14 +202,15 @@ rend_mid_introduce(or_circuit_t *circ, const uint8_t *request,
(char*)request, request_len, NULL)) { (char*)request, request_len, NULL)) {
log_warn(LD_GENERAL, log_warn(LD_GENERAL,
"Unable to send INTRODUCE2 cell to Tor client."); "Unable to send INTRODUCE2 cell to Tor client.");
goto err; /* Stop right now, the circuit has been closed. */
return -1;
} }
/* And send an ack down the client's circuit. Empty body means succeeded. */ /* And send an ack down the client's circuit. Empty body means succeeded. */
if (relay_send_command_from_edge(0,TO_CIRCUIT(circ), if (relay_send_command_from_edge(0,TO_CIRCUIT(circ),
RELAY_COMMAND_INTRODUCE_ACK, RELAY_COMMAND_INTRODUCE_ACK,
NULL,0,NULL)) { NULL,0,NULL)) {
log_warn(LD_GENERAL, "Unable to send INTRODUCE_ACK cell to Tor client."); log_warn(LD_GENERAL, "Unable to send INTRODUCE_ACK cell to Tor client.");
circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL); /* Stop right now, the circuit has been closed. */
return -1; return -1;
} }
@ -220,8 +222,6 @@ rend_mid_introduce(or_circuit_t *circ, const uint8_t *request,
RELAY_COMMAND_INTRODUCE_ACK, RELAY_COMMAND_INTRODUCE_ACK,
nak_body, 1, NULL)) { nak_body, 1, NULL)) {
log_warn(LD_GENERAL, "Unable to send NAK to Tor client."); log_warn(LD_GENERAL, "Unable to send NAK to Tor client.");
/* Is this right? */
circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_INTERNAL);
} }
return -1; return -1;
} }
@ -269,8 +269,8 @@ rend_mid_establish_rendezvous(or_circuit_t *circ, const uint8_t *request,
RELAY_COMMAND_RENDEZVOUS_ESTABLISHED, RELAY_COMMAND_RENDEZVOUS_ESTABLISHED,
"", 0, NULL)<0) { "", 0, NULL)<0) {
log_warn(LD_PROTOCOL, "Couldn't send RENDEZVOUS_ESTABLISHED cell."); log_warn(LD_PROTOCOL, "Couldn't send RENDEZVOUS_ESTABLISHED cell.");
reason = END_CIRC_REASON_INTERNAL; /* Stop right now, the circuit has been closed. */
goto err; return -1;
} }
circuit_change_purpose(TO_CIRCUIT(circ), CIRCUIT_PURPOSE_REND_POINT_WAITING); circuit_change_purpose(TO_CIRCUIT(circ), CIRCUIT_PURPOSE_REND_POINT_WAITING);
@ -346,7 +346,8 @@ rend_mid_rendezvous(or_circuit_t *circ, const uint8_t *request,
log_warn(LD_GENERAL, log_warn(LD_GENERAL,
"Unable to send RENDEZVOUS2 cell to client on circuit %u.", "Unable to send RENDEZVOUS2 cell to client on circuit %u.",
(unsigned)rend_circ->p_circ_id); (unsigned)rend_circ->p_circ_id);
goto err; /* Stop right now, the circuit has been closed. */
return -1;
} }
/* Join the circuits. */ /* Join the circuits. */

View File

@ -3066,8 +3066,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
log_info(LD_GENERAL, log_info(LD_GENERAL,
"Couldn't send introduction request for service %s on circuit %u", "Couldn't send introduction request for service %s on circuit %u",
serviceid, (unsigned)circuit->base_.n_circ_id); serviceid, (unsigned)circuit->base_.n_circ_id);
reason = END_CIRC_REASON_INTERNAL; goto done;
goto err;
} }
/* We've attempted to use this circuit */ /* We've attempted to use this circuit */
@ -3229,8 +3228,7 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit)
buf, REND_COOKIE_LEN+DH_KEY_LEN+DIGEST_LEN, buf, REND_COOKIE_LEN+DH_KEY_LEN+DIGEST_LEN,
circuit->cpath->prev)<0) { circuit->cpath->prev)<0) {
log_warn(LD_GENERAL, "Couldn't send RENDEZVOUS1 cell."); log_warn(LD_GENERAL, "Couldn't send RENDEZVOUS1 cell.");
reason = END_CIRC_REASON_INTERNAL; goto done;
goto err;
} }
crypto_dh_free(hop->rend_dh_handshake_state); crypto_dh_free(hop->rend_dh_handshake_state);