aboutsummaryrefslogtreecommitdiff
path: root/src/or/rephist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-12-07 20:11:36 +0000
committerNick Mathewson <nickm@torproject.org>2006-12-07 20:11:36 +0000
commitb4a90ca8a3e0a29afc2f2068cdfd02044e242965 (patch)
tree9e573de0a614c2269add61deecdef24535be07d5 /src/or/rephist.c
parent7c79495137bcd3989428d65b184038aa71fbae70 (diff)
downloadtor-b4a90ca8a3e0a29afc2f2068cdfd02044e242965.tar.gz
tor-b4a90ca8a3e0a29afc2f2068cdfd02044e242965.zip
r11469@Kushana: nickm | 2006-12-07 15:11:04 -0500
Round stored/transmitted values for bandwidth usage. This might make some attacks work less well. This might well be voodoo, but it gives me a warm fuzzy feeling. svn:r9048
Diffstat (limited to 'src/or/rephist.c')
-rw-r--r--src/or/rephist.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/or/rephist.c b/src/or/rephist.c
index af295facf3..19b6ea23bf 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -596,13 +596,14 @@ rep_hist_fill_bandwidth_history(char *buf, size_t len, bw_array_t *b)
}
for (n=0; n<b->num_maxes_set; ++n,++i) {
+ uint64_t total;
while (i >= NUM_TOTALS) i -= NUM_TOTALS;
+ /* Round the bandwidth used down to the nearest 1k. */
+ total = b->totals[i] & ~0x3ff;
if (n==(b->num_maxes_set-1))
- tor_snprintf(cp, len-(cp-buf), U64_FORMAT,
- U64_PRINTF_ARG(b->totals[i]));
+ tor_snprintf(cp, len-(cp-buf), U64_FORMAT, U64_PRINTF_ARG(total));
else
- tor_snprintf(cp, len-(cp-buf), U64_FORMAT",",
- U64_PRINTF_ARG(b->totals[i]));
+ tor_snprintf(cp, len-(cp-buf), U64_FORMAT",", U64_PRINTF_ARG(total));
cp += strlen(cp);
}
return cp-buf;