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

[tor-commits] [tor/master] Test that regular cells get ignored in padding circuits.



commit 1e970d17b8e028ec6bd2fa9e0d88dc54209e0523
Author: George Kadianakis <desnacked@xxxxxxxxxx>
Date:   Tue Jul 23 13:52:36 2019 +0300

    Test that regular cells get ignored in padding circuits.
---
 src/core/or/relay.c            |  8 +++-----
 src/core/or/relay.h            |  5 +++++
 src/test/test_circuitpadding.c | 26 ++++++++++++++++++++++++++
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/src/core/or/relay.c b/src/core/or/relay.c
index 3b5aa2b66..ac3f2a8bb 100644
--- a/src/core/or/relay.c
+++ b/src/core/or/relay.c
@@ -1584,12 +1584,10 @@ process_sendme_cell(const relay_header_t *rh, const cell_t *cell,
  *  unpacked by the parent function, and <b>optimistic_data</b> as set by the
  *  parent function.
  */
-static int
+STATIC int
 handle_relay_command(cell_t *cell, circuit_t *circ,
-                     edge_connection_t *conn,
-                     crypt_path_t *layer_hint,
-                     relay_header_t *rh,
-                     int optimistic_data)
+                     edge_connection_t *conn, crypt_path_t *layer_hint,
+                     relay_header_t *rh, int optimistic_data)
 {
   unsigned domain = layer_hint?LD_APP:LD_EXIT;
   int reason;
diff --git a/src/core/or/relay.h b/src/core/or/relay.h
index 79036f97b..d9e0d533f 100644
--- a/src/core/or/relay.h
+++ b/src/core/or/relay.h
@@ -99,6 +99,11 @@ circid_t packed_cell_get_circid(const packed_cell_t *cell, int wide_circ_ids);
 uint8_t packed_cell_get_command(const packed_cell_t *cell, int wide_circ_ids);
 
 #ifdef RELAY_PRIVATE
+STATIC int
+handle_relay_command(cell_t *cell, circuit_t *circ,
+                     edge_connection_t *conn, crypt_path_t *layer_hint,
+                     relay_header_t *rh, int optimistic_data);
+
 STATIC int connected_cell_parse(const relay_header_t *rh, const cell_t *cell,
                          tor_addr_t *addr_out, int *ttl_out);
 /** An address-and-ttl tuple as yielded by resolved_cell_parse */
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c
index 236f4a192..8575e6ced 100644
--- a/src/test/test_circuitpadding.c
+++ b/src/test/test_circuitpadding.c
@@ -4,9 +4,11 @@
 #define CIRCUITPADDING_MACHINES_PRIVATE
 #define NETWORKSTATUS_PRIVATE
 #define CRYPT_PATH_PRIVATE
+#define RELAY_PRIVATE
 
 #include "core/or/or.h"
 #include "test/test.h"
+#include "test/log_test_helpers.h"
 #include "lib/testsupport/testsupport.h"
 #include "core/or/connection_or.h"
 #include "core/or/channel.h"
@@ -3152,6 +3154,29 @@ test_circuitpadding_hs_machines(void *arg)
   UNMOCK(circpad_machine_schedule_padding);
 }
 
+/** Test that we effectively ignore non-padding cells in padding circuits. */
+static void
+test_circuitpadding_ignore_non_padding_cells(void *arg)
+{
+  int retval;
+  relay_header_t rh;
+
+  (void) arg;
+
+  client_side = (circuit_t *)origin_circuit_new();
+  client_side->purpose = CIRCUIT_PURPOSE_C_CIRCUIT_PADDING;
+
+  rh.command = RELAY_COMMAND_BEGIN;
+
+  setup_full_capture_of_logs(LOG_INFO);
+  retval = handle_relay_command(NULL, client_side, NULL, NULL, &rh, 0);
+  tt_int_op(retval, OP_EQ, 0);
+  expect_log_msg_containing("Ignored cell");
+
+ done:
+  ;
+}
+
 #define TEST_CIRCUITPADDING(name, flags) \
     { #name, test_##name, (flags), NULL, NULL }
 
@@ -3175,5 +3200,6 @@ struct testcase_t circuitpadding_tests[] = {
   TEST_CIRCUITPADDING(circuitpadding_token_removal_exact, TT_FORK),
   TEST_CIRCUITPADDING(circuitpadding_manage_circuit_lifetime, TT_FORK),
   TEST_CIRCUITPADDING(circuitpadding_hs_machines, TT_FORK),
+  TEST_CIRCUITPADDING(circuitpadding_ignore_non_padding_cells, TT_FORK),
   END_OF_TESTCASES
 };



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