diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-06-04 11:40:52 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-06-04 11:40:52 -0400 |
commit | 491dc3a601d7c2610503f73192bd1a40bcb37ab2 (patch) | |
tree | 30b36aed9f32d51dcb8513edee08c5898df60e17 /src/or | |
parent | 6d85a796539424882f878ccac5ae4640a6fbb561 (diff) | |
parent | af54a0182870babec62bf07d067ca82a67c423de (diff) | |
download | tor-491dc3a601d7c2610503f73192bd1a40bcb37ab2.tar tor-491dc3a601d7c2610503f73192bd1a40bcb37ab2.tar.gz |
Merge remote-tracking branch 'public/bug6007_strict_squashed' into maint-0.2.2
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/connection_or.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/or/connection_or.c b/src/or/connection_or.c index dc8850ea3..cb0082bdc 100644 --- a/src/or/connection_or.c +++ b/src/or/connection_or.c @@ -209,7 +209,12 @@ connection_or_reached_eof(or_connection_t *conn) int connection_or_process_inbuf(or_connection_t *conn) { - int ret; + /** Don't let the inbuf of a nonopen OR connection grow beyond this many + * bytes: it's either a broken client, a non-Tor client, or a DOS + * attempt. */ +#define MAX_OR_INBUF_WHEN_NONOPEN 0 + + int ret = 0; tor_assert(conn); switch (conn->_base.state) { @@ -231,8 +236,21 @@ connection_or_process_inbuf(or_connection_t *conn) case OR_CONN_STATE_OR_HANDSHAKING: return connection_or_process_cells_from_inbuf(conn); default: - return 0; /* don't do anything */ + break; /* don't do anything */ } + + if (buf_datalen(conn->_base.inbuf) > MAX_OR_INBUF_WHEN_NONOPEN) { + log_fn(LOG_PROTOCOL_WARN, LD_NET, "Accumulated too much data (%d bytes) " + "on nonopen OR connection %s %s:%u in state %s; closing.", + (int)buf_datalen(conn->_base.inbuf), + connection_or_nonopen_was_started_here(conn) ? "to" : "from", + conn->_base.address, conn->_base.port, + conn_state_to_string(conn->_base.type, conn->_base.state)); + connection_mark_for_close(TO_CONN(conn)); + ret = -1; + } + + return ret; } /** When adding cells to an OR connection's outbuf, keep adding until the |