diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-07-06 05:56:03 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-07-06 17:07:12 +0200 |
commit | 0cadfc6954dbc1b61f11d949b4961c455e4fca8e (patch) | |
tree | 4d75b96f801c2bc898c2a0540fed42eab64aaca3 | |
parent | ratelimiter: add self-test (diff) | |
download | wireguard-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.
-rw-r--r-- | src/data.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -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); |