Fix bounds check error in duplicate detection
This commit is contained in:
parent
75d4050307
commit
f245ebe63f
3 changed files with 11 additions and 5 deletions
|
|
@ -324,7 +324,7 @@ class MessageReceptionState:
|
||||||
else:
|
else:
|
||||||
new_bitmap = (self.window_bitmap << shift) & self.mask
|
new_bitmap = (self.window_bitmap << shift) & self.mask
|
||||||
self.window_bitmap = new_bitmap
|
self.window_bitmap = new_bitmap
|
||||||
if 1 < shift < MSG_COUNTER_WINDOW_SIZE:
|
if 1 <= shift < MSG_COUNTER_WINDOW_SIZE:
|
||||||
self.window_bitmap |= 1 << (shift - 1)
|
self.window_bitmap |= 1 << (shift - 1)
|
||||||
self.message_counter = counter
|
self.message_counter = counter
|
||||||
return False
|
return False
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
cryptography==41.0.7
|
cryptography
|
||||||
ecdsa==0.18.0
|
ecdsa
|
||||||
qrcode==7.4.2
|
qrcode
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,19 @@ def test_basics():
|
||||||
# The current max is not ok
|
# The current max is not ok
|
||||||
assert state.process_counter(123)
|
assert state.process_counter(123)
|
||||||
|
|
||||||
|
# A current max + 1 is ok
|
||||||
|
assert not state.process_counter(124)
|
||||||
|
|
||||||
|
# Old current max isn't
|
||||||
|
assert state.process_counter(123)
|
||||||
|
|
||||||
# A new value is ok
|
# A new value is ok
|
||||||
assert not state.process_counter(126)
|
assert not state.process_counter(126)
|
||||||
|
|
||||||
#
|
#
|
||||||
assert state.process_counter(123)
|
assert state.process_counter(123)
|
||||||
|
|
||||||
assert not state.process_counter(124)
|
assert state.process_counter(124)
|
||||||
|
|
||||||
assert not state.process_counter(125)
|
assert not state.process_counter(125)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue