From b4a90ca8a3e0a29afc2f2068cdfd02044e242965 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 7 Dec 2006 20:11:36 +0000 Subject: 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 --- src/or/rephist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/or/rephist.c') 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; nnum_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; -- cgit v1.2.3-54-g00ecf