Skip to content

Commit

Permalink
Fix bounds check error in duplicate detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Oct 18, 2024
1 parent 75d4050 commit f245ebe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion circuitmatter/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def process_counter(self, counter) -> bool:
else:
new_bitmap = (self.window_bitmap << shift) & self.mask
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.message_counter = counter
return False
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
cryptography==41.0.7
ecdsa==0.18.0
qrcode==7.4.2
cryptography
ecdsa
qrcode
8 changes: 7 additions & 1 deletion tests/test_message_reception_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ def test_basics():
# The current max is not ok
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
assert not state.process_counter(126)

#
assert state.process_counter(123)

assert not state.process_counter(124)
assert state.process_counter(124)

assert not state.process_counter(125)

Expand Down

0 comments on commit f245ebe

Please sign in to comment.