[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Bug 26259: Don't count 0-length RELAY_COMMAND_DATA in CIRC_BW OVERHEAD



commit 93ee227e180686ab582c0d8199fe07f20046e8d7
Author: Mike Perry <mikeperry-git@xxxxxxxxxxxxxx>
Date:   Fri Jun 1 00:23:08 2018 +0000

    Bug 26259: Don't count 0-length RELAY_COMMAND_DATA in CIRC_BW OVERHEAD
    
    This cell should be treated as invalid for purposes of CIRC_BW.
---
 src/or/relay.c            | 2 +-
 src/test/test_relaycell.c | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/or/relay.c b/src/or/relay.c
index 0aa15203f..50f59d6b9 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -1556,7 +1556,7 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
         return -END_CIRC_REASON_TORPROTOCOL;
       }
       /* Total all valid application bytes delivered */
-      if (CIRCUIT_IS_ORIGIN(circ)) {
+      if (CIRCUIT_IS_ORIGIN(circ) && rh.length > 0) {
         circuit_read_valid_data(TO_ORIGIN_CIRCUIT(circ), rh.length);
       }
 
diff --git a/src/test/test_relaycell.c b/src/test/test_relaycell.c
index 1db520273..52f4d6113 100644
--- a/src/test/test_relaycell.c
+++ b/src/test/test_relaycell.c
@@ -233,6 +233,13 @@ test_circbw_relay(void *arg)
                                      circ->cpath);
   ASSERT_COUNTED_BW();
 
+  /* Empty Data cell on open connection: not counted */
+  ENTRY_TO_CONN(entryconn)->marked_for_close = 0;
+  PACK_CELL(1, RELAY_COMMAND_DATA, "");
+  connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), edgeconn,
+                                     circ->cpath);
+  ASSERT_UNCOUNTED_BW();
+
   /* Sendme on stream: not counted */
   ENTRY_TO_CONN(entryconn)->outbuf_flushlen = 0;
   PACK_CELL(1, RELAY_COMMAND_SENDME, "Data1234");



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