diff options
author | Roger Dingledine <arma@torproject.org> | 2012-06-28 14:00:01 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-07-18 10:23:04 -0400 |
commit | c1bd10411116c549326f74b09658a50bbae812b4 (patch) | |
tree | ca33a270b3c3da6d68f68fdd847ef807abdaac48 /src | |
parent | b355ddb20f534d772dcb42737ceb1d0264e2c3f1 (diff) | |
download | tor-c1bd10411116c549326f74b09658a50bbae812b4.tar tor-c1bd10411116c549326f74b09658a50bbae812b4.tar.gz |
Detect bug 6252 (unexpected sendme cell)
I only check on circuits, not streams, since bloating your stream
window past the initial circuit window can't help you much.
Also, I compare to CIRCWINDOW_START_MAX so we don't have surprising
races if we lower CIRCWINDOW_START for an experiment.
Diffstat (limited to 'src')
-rw-r--r-- | src/or/relay.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/relay.c b/src/or/relay.c index 3e418ea13..3d261c265 100644 --- a/src/or/relay.c +++ b/src/or/relay.c @@ -1265,11 +1265,25 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ, case RELAY_COMMAND_SENDME: if (!rh.stream_id) { if (layer_hint) { + if (layer_hint->package_window + CIRCWINDOW_INCREMENT > + CIRCWINDOW_START_MAX) { + log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL, + "Bug/attack: unexpected sendme cell from exit relay. " + "Closing circ."); + return -END_CIRC_REASON_TORPROTOCOL; + } layer_hint->package_window += CIRCWINDOW_INCREMENT; log_debug(LD_APP,"circ-level sendme at origin, packagewindow %d.", layer_hint->package_window); circuit_resume_edge_reading(circ, layer_hint); } else { + if (circ->package_window + CIRCWINDOW_INCREMENT > + CIRCWINDOW_START_MAX) { + log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL, + "Bug/attack: unexpected sendme cell from client. " + "Closing circ."); + return -END_CIRC_REASON_TORPROTOCOL; + } circ->package_window += CIRCWINDOW_INCREMENT; log_debug(LD_APP, "circ-level sendme at non-origin, packagewindow %d.", |