summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMicah Elizabeth Scott <beth@torproject.org>2023-08-11 18:05:07 -0700
committerMicah Elizabeth Scott <beth@torproject.org>2023-08-11 18:05:07 -0700
commitd0343b12c68891d655cf313cdca2696460a75833 (patch)
treed0e598b72ffc1f0cf929d6977adbdd5b28156ed5
parent2b8d629079414347128aa875d864d4e734980a5c (diff)
downloadtor-d0343b12c68891d655cf313cdca2696460a75833.tar.gz
tor-d0343b12c68891d655cf313cdca2696460a75833.zip
test_dos: Fixes for uninitialized stack memory
This was causing CI failures that didn't reproduce on my local machine. The DoS subsystem now has a new assert() which triggers a BUG on some nonzero memory contents (or_conn->tracked_for_dos_mitigation), and uninitialized stack memory might be nonzero.
-rw-r--r--src/test/test_dos.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/test/test_dos.c b/src/test/test_dos.c
index 388a4bee66..6c57e85cb8 100644
--- a/src/test/test_dos.c
+++ b/src/test/test_dos.c
@@ -72,6 +72,7 @@ test_dos_conn_creation(void *arg)
/* Initialize test data */
or_connection_t or_conn;
+ memset(&or_conn, 0, sizeof or_conn);
time_t wallclock_now = 1281533250; /* 2010-08-11 13:27:30 UTC */
tt_int_op(AF_INET,OP_EQ, tor_addr_parse(&TO_CONN(&or_conn)->addr,
"18.0.0.1"));
@@ -153,6 +154,7 @@ test_dos_circuit_creation(void *arg)
/* Initialize test data */
or_connection_t or_conn;
+ memset(&or_conn, 0, sizeof or_conn);
time_t now = 1281533250; /* 2010-08-11 13:27:30 UTC */
tt_int_op(AF_INET,OP_EQ, tor_addr_parse(&TO_CONN(&or_conn)->addr,
"18.0.0.1"));
@@ -218,6 +220,7 @@ test_dos_bucket_refill(void *arg)
channel_init(chan);
chan->is_client = 1;
or_connection_t or_conn;
+ memset(&or_conn, 0, sizeof or_conn);
tt_int_op(AF_INET,OP_EQ, tor_addr_parse(&TO_CONN(&or_conn)->addr,
"18.0.0.1"));
tor_addr_t *addr = &TO_CONN(&or_conn)->addr;
@@ -459,6 +462,7 @@ test_known_relay(void *arg)
/* Setup an OR conn so we can pass it to the DoS subsystem. */
or_connection_t or_conn;
+ memset(&or_conn, 0, sizeof or_conn);
tor_addr_parse(&TO_CONN(&or_conn)->addr, "42.42.42.42");
rs = tor_malloc_zero(sizeof(*rs));
@@ -514,6 +518,7 @@ test_dos_conn_rate(void *arg)
/* Initialize test data */
or_connection_t or_conn;
+ memset(&or_conn, 0, sizeof or_conn);
time_t now = 1281533250; /* 2010-08-11 13:27:30 UTC */
tt_int_op(AF_INET,OP_EQ, tor_addr_parse(&TO_CONN(&or_conn)->addr,
"18.0.0.1"));