[tor-commits] [tor/maint-0.2.4] Send NETINFO on receiving a NETINFO if we have not yet sent one.

2013-08-24 Thread nickm
commit 1bb4a4f9bdf24706a459e4aefb2b0fb75622f7ac
Author: Nick Mathewson 
Date:   Tue Aug 20 14:52:56 2013 -0400

Send NETINFO on receiving a NETINFO if we have not yet sent one.

Relays previously, when initiating a connection, would only send a
NETINFO after sending an AUTHENTICATE.  But bridges, when receiving a
connection, would never send AUTH_CHALLENGE.  So relays wouldn't
AUTHENTICATE, and wouldn't NETINFO, and then bridges would be
surprised to be receiving CREATE cells on a non-open circuit.

Fixes bug 9546.
---
 changes/bug9546|5 +
 src/or/channeltls.c|   10 ++
 src/or/connection_or.c |7 +++
 src/or/or.h|3 +++
 4 files changed, 25 insertions(+)

diff --git a/changes/bug9546 b/changes/bug9546
new file mode 100644
index 000..8596eac
--- /dev/null
+++ b/changes/bug9546
@@ -0,0 +1,5 @@
+  o Major bugfixes:
+
+- When a relay is extending a circuit to a bridge, it needs to send a
+  NETINFO cell, even when the bridge hasn't sent an AUTH_CHALLENGE
+  cell. Fixes bug 9546; bugfix on .
diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index d758d22..a7953e7 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -1474,6 +1474,16 @@ channel_tls_process_netinfo_cell(cell_t *cell, 
channel_tls_t *chan)
   /* XXX maybe act on my_apparent_addr, if the source is sufficiently
* trustworthy. */
 
+  if (! chan->conn->handshake_state->sent_netinfo) {
+/* If we were prepared to authenticate, but we never got an AUTH_CHALLENGE
+ * cell, then we would not previously have sent a NETINFO cell. Do so
+ * now. */
+if (connection_or_send_netinfo(chan->conn) < 0) {
+  connection_or_close_for_error(chan->conn, 0);
+  return;
+}
+  }
+
   if (connection_or_set_state_open(chan->conn) < 0) {
 log_fn(LOG_PROTOCOL_WARN, LD_OR,
"Got good NETINFO cell from %s:%d; but "
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 3616363..31cc9c7 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -2042,6 +2042,12 @@ connection_or_send_netinfo(or_connection_t *conn)
 
   tor_assert(conn->handshake_state);
 
+  if (conn->handshake_state->sent_netinfo) {
+log_warn(LD_BUG, "Attempted to send an extra netinfo cell on a connection "
+ "where we already sent one.");
+return 0;
+  }
+
   memset(&cell, 0, sizeof(cell_t));
   cell.command = CELL_NETINFO;
 
@@ -2083,6 +2089,7 @@ connection_or_send_netinfo(or_connection_t *conn)
   }
 
   conn->handshake_state->digest_sent_data = 0;
+  conn->handshake_state->sent_netinfo = 1;
   connection_or_write_cell_to_buf(&cell, conn);
 
   return 0;
diff --git a/src/or/or.h b/src/or/or.h
index 3dc96b9..8c6c1e3 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1357,6 +1357,9 @@ typedef struct or_handshake_state_t {
   /* True iff we've received valid authentication to some identity. */
   unsigned int authenticated : 1;
 
+  /* True iff we have sent a netinfo cell */
+  unsigned int sent_netinfo : 1;
+
   /** True iff we should feed outgoing cells into digest_sent and
* digest_received respectively.
*



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits


[tor-commits] [tor/maint-0.2.4] Send NETINFO on receiving a NETINFO if we have not yet sent one.

2013-08-24 Thread nickm
commit 0daa26a4732234333e67d04c9b215ff6704fa9cd
Author: Nick Mathewson 
Date:   Tue Aug 20 14:52:56 2013 -0400

Send NETINFO on receiving a NETINFO if we have not yet sent one.

(Backport to Tor 0.2.3)

Relays previously, when initiating a connection, would only send a
NETINFO after sending an AUTHENTICATE.  But bridges, when receiving a
connection, would never send AUTH_CHALLENGE.  So relays wouldn't
AUTHENTICATE, and wouldn't NETINFO, and then bridges would be
surprised to be receiving CREATE cells on a non-open circuit.

Fixes bug 9546.
---
 bug9546|5 +
 src/or/command.c   |   10 ++
 src/or/connection_or.c |7 +++
 src/or/or.h|3 +++
 4 files changed, 25 insertions(+)

diff --git a/bug9546 b/bug9546
new file mode 100644
index 000..8596eac
--- /dev/null
+++ b/bug9546
@@ -0,0 +1,5 @@
+  o Major bugfixes:
+
+- When a relay is extending a circuit to a bridge, it needs to send a
+  NETINFO cell, even when the bridge hasn't sent an AUTH_CHALLENGE
+  cell. Fixes bug 9546; bugfix on .
diff --git a/src/or/command.c b/src/or/command.c
index 8321e26..26e4e68 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -941,6 +941,16 @@ command_process_netinfo_cell(cell_t *cell, or_connection_t 
*conn)
* trustworthy. */
   (void)my_apparent_addr;
 
+  if (! conn->handshake_state->sent_netinfo) {
+/* If we were prepared to authenticate, but we never got an AUTH_CHALLENGE
+ * cell, then we would not previously have sent a NETINFO cell. Do so
+ * now. */
+if (connection_or_send_netinfo(conn) < 0) {
+  connection_mark_for_close(TO_CONN(conn));
+  return;
+}
+  }
+
   if (connection_or_set_state_open(conn)<0) {
 log_fn(LOG_PROTOCOL_WARN, LD_OR, "Got good NETINFO cell from %s:%d; but "
"was unable to make the OR connection become open.",
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 5eecee0..56c6ed5 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -1975,6 +1975,12 @@ connection_or_send_netinfo(or_connection_t *conn)
 
   tor_assert(conn->handshake_state);
 
+  if (conn->handshake_state->sent_netinfo) {
+log_warn(LD_BUG, "Attempted to send an extra netinfo cell on a connection "
+ "where we already sent one.");
+return 0;
+  }
+
   memset(&cell, 0, sizeof(cell_t));
   cell.command = CELL_NETINFO;
 
@@ -2009,6 +2015,7 @@ connection_or_send_netinfo(or_connection_t *conn)
   }
 
   conn->handshake_state->digest_sent_data = 0;
+  conn->handshake_state->sent_netinfo = 1;
   connection_or_write_cell_to_buf(&cell, conn);
 
   return 0;
diff --git a/src/or/or.h b/src/or/or.h
index dd95c34..b8f334e 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1161,6 +1161,9 @@ typedef struct or_handshake_state_t {
   /* True iff we've received valid authentication to some identity. */
   unsigned int authenticated : 1;
 
+  /* True iff we have sent a netinfo cell */
+  unsigned int sent_netinfo : 1;
+
   /** True iff we should feed outgoing cells into digest_sent and
* digest_received respectively.
*



___
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits