aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/data.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-07-06 05:56:03 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-07-06 17:07:12 +0200
commit0cadfc6954dbc1b61f11d949b4961c455e4fca8e (patch)
tree4d75b96f801c2bc898c2a0540fed42eab64aaca3 /src/data.c
parentratelimiter: add self-test (diff)
downloadwireguard-monolithic-historical-0cadfc6954dbc1b61f11d949b4961c455e4fca8e.tar.xz
wireguard-monolithic-historical-0cadfc6954dbc1b61f11d949b4961c455e4fca8e.zip
counter: use correct unit for indices
Even though redundant bits == bits per long, we're indexing into something that uses longs as its unit, so this is correct.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/data.c b/src/data.c
index 59e9714..be6bf7f 100644
--- a/src/data.c
+++ b/src/data.c
@@ -68,10 +68,10 @@ static inline bool counter_validate(union noise_counter *counter, u64 their_coun
if (unlikely((COUNTER_WINDOW_SIZE + their_counter) < counter->receive.counter))
goto out;
- index = their_counter >> ilog2(COUNTER_REDUNDANT_BITS);
+ index = their_counter >> ilog2(BITS_PER_LONG);
if (likely(their_counter > counter->receive.counter)) {
- index_current = counter->receive.counter >> ilog2(COUNTER_REDUNDANT_BITS);
+ index_current = counter->receive.counter >> ilog2(BITS_PER_LONG);
top = min_t(unsigned long, index - index_current, COUNTER_BITS_TOTAL / BITS_PER_LONG);
for (i = 1; i <= top; ++i)
counter->receive.backtrack[(i + index_current) & ((COUNTER_BITS_TOTAL / BITS_PER_LONG) - 1)] = 0;
@@ -79,7 +79,7 @@ static inline bool counter_validate(union noise_counter *counter, u64 their_coun
}
index &= (COUNTER_BITS_TOTAL / BITS_PER_LONG) - 1;
- ret = !test_and_set_bit(their_counter & (COUNTER_REDUNDANT_BITS - 1), &counter->receive.backtrack[index]);
+ ret = !test_and_set_bit(their_counter & (BITS_PER_LONG - 1), &counter->receive.backtrack[index]);
out:
spin_unlock_bh(&counter->receive.lock);