Skip to content

Commit f245ebe

Browse files
committed
Fix bounds check error in duplicate detection
1 parent 75d4050 commit f245ebe

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

circuitmatter/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def process_counter(self, counter) -> bool:
324324
else:
325325
new_bitmap = (self.window_bitmap << shift) & self.mask
326326
self.window_bitmap = new_bitmap
327-
if 1 < shift < MSG_COUNTER_WINDOW_SIZE:
327+
if 1 <= shift < MSG_COUNTER_WINDOW_SIZE:
328328
self.window_bitmap |= 1 << (shift - 1)
329329
self.message_counter = counter
330330
return False

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
cryptography==41.0.7
2-
ecdsa==0.18.0
3-
qrcode==7.4.2
1+
cryptography
2+
ecdsa
3+
qrcode

tests/test_message_reception_state.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ def test_basics():
1212
# The current max is not ok
1313
assert state.process_counter(123)
1414

15+
# A current max + 1 is ok
16+
assert not state.process_counter(124)
17+
18+
# Old current max isn't
19+
assert state.process_counter(123)
20+
1521
# A new value is ok
1622
assert not state.process_counter(126)
1723

1824
#
1925
assert state.process_counter(123)
2026

21-
assert not state.process_counter(124)
27+
assert state.process_counter(124)
2228

2329
assert not state.process_counter(125)
2430

0 commit comments

Comments
 (0)