]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Merge remote-tracking branch 'origin/maint-0.2.2'
authorNick Mathewson <nickm@torproject.org>
Fri, 28 Oct 2011 22:02:57 +0000 (18:02 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 28 Oct 2011 22:02:57 +0000 (18:02 -0400)
Conflicts:
src/or/command.c

1  2 
src/or/command.c

index d35e2a9c80b7cbd82b4c8f6380a6d97bb1191e49,5271a7a907f53c3bdeb8a370a143c3d29dcb4ebc..43d304e07bad7712d56e0360b715ae3d2f2ae13e
@@@ -148,19 -132,13 +148,22 @@@ command_process_cell(cell_t *cell, or_c
  #define PROCESS_CELL(tp, cl, cn) command_process_ ## tp ## _cell(cl, cn)
  #endif
  
+   if (conn->_base.marked_for_close)
+     return;
    /* 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;
 +  }
 +
 +  if (conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
 +    or_handshake_state_record_cell(conn->handshake_state, cell, 1);
  
    switch (cell->command) {
      case CELL_PADDING:
@@@ -230,53 -208,12 +233,56 @@@ command_process_var_cell(var_cell_t *ce
    }
  #endif
  
 -  /* reject all when not handshaking. */
 -  if (conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING)
 -    return;
+   if (conn->_base.marked_for_close)
+     return;
 +  switch (conn->_base.state)
 +  {
 +    case OR_CONN_STATE_OR_HANDSHAKING_V2:
 +      if (cell->command != CELL_VERSIONS)
 +        return;
 +      break;
 +    case OR_CONN_STATE_TLS_HANDSHAKING:
 +      /* If we're using bufferevents, it's entirely possible for us to
 +       * notice "hey, data arrived!" before we notice "hey, the handshake
 +       * finished!" And we need to be accepting both at once to handle both
 +       * the v2 and v3 handshakes. */
 +
 +      /* fall through */
 +    case OR_CONN_STATE_TLS_SERVER_RENEGOTIATING:
 +      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) {
 +        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:
 +      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;
 +  }
  
    switch (cell->command) {
      case CELL_VERSIONS: