summaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-10-06 14:58:59 -0400
committerNick Mathewson <nickm@torproject.org>2011-10-10 23:14:31 -0400
commit1bd65680bdfcd46e1c96e71e3912cbdef4fc158a (patch)
tree2c74b4fbd250d3175964a41d4fe809e409c13df8 /src/or/command.c
parent059d3d06132048135bd45a1ecf23a62731b3a8cc (diff)
downloadtor-1bd65680bdfcd46e1c96e71e3912cbdef4fc158a.tar.gz
tor-1bd65680bdfcd46e1c96e71e3912cbdef4fc158a.zip
Add more log statements for protocol/internal failures
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 7efd18fcec..8cf6c46401 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -149,10 +149,15 @@ command_process_cell(cell_t *cell, or_connection_t *conn)
#endif
/* Reject all but VERSIONS and NETINFO when handshaking. */
+ /* (VERSIONS should actually be impossible; it's variable-length.) */
if (handshaking && cell->command != CELL_VERSIONS &&
- cell->command != CELL_NETINFO)
+ cell->command != CELL_NETINFO) {
+ log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+ "Received unexpected cell command %d in state %s; ignoring it.",
+ (int)cell->command,
+ conn_state_to_string(CONN_TYPE_OR,conn->_base.state));
return;
- /* XXXX VERSIONS should be impossible; it's variable-length. */
+ }
if (conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
or_handshake_state_record_cell(conn->handshake_state, cell, 1);
@@ -239,18 +244,37 @@ command_process_var_cell(var_cell_t *cell, or_connection_t *conn)
/* fall through */
case OR_CONN_STATE_TLS_SERVER_RENEGOTIATING:
- if (cell->command != CELL_VERSIONS)
- return; /*XXXX023 log*/
+ if (cell->command != CELL_VERSIONS) {
+ log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+ "Received a non-VERSIONS cell with command %d in state %s; "
+ "ignoring it.",
+ (int)cell->command,
+ conn_state_to_string(CONN_TYPE_OR,conn->_base.state));
+ return;
+ }
break;
case OR_CONN_STATE_OR_HANDSHAKING_V3:
if (cell->command != CELL_AUTHENTICATE)
or_handshake_state_record_var_cell(conn->handshake_state, cell, 1);
break; /* Everything is allowed */
case OR_CONN_STATE_OPEN:
- if (conn->link_proto < 3)
+ if (conn->link_proto < 3) {
+ log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+ "Received a variable-length cell with command %d in state %s "
+ "with link protocol %d; ignoring it.",
+ (int)cell->command,
+ conn_state_to_string(CONN_TYPE_OR,conn->_base.state),
+ (int)conn->link_proto);
return;
+ }
+ break;
default:
- /*XXXX023 log */
+ log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+ "Received var-length cell with command %d in unexpected state "
+ "%s [%d]; ignoring it.",
+ (int)cell->command,
+ conn_state_to_string(CONN_TYPE_OR,conn->_base.state),
+ (int)conn->_base.state);
return;
}