Skip to content

Commit 4240105

Browse files
authored
Handle replay after wrapping in replaydetector (#681)
1 parent 86a2b00 commit 4240105

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

util/src/replay_detector/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ impl ReplayDetector for WrappedSlidingWindowDetector {
160160
// Update the head of the window.
161161
self.mask.lsh((-diff) as usize);
162162
self.latest_seq = self.seq;
163+
self.mask.set_bit(0);
164+
} else {
165+
self.mask.set_bit(diff as usize);
163166
}
164-
self.mask
165-
.set_bit((self.latest_seq as isize - self.seq as isize) as usize);
166167
}
167168
}
168169

util/src/replay_detector/replay_detector_test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ fn test_replay_detector() {
248248
0xFFFD, 0xFFFC, 0x0002, 0xFFFE, 0x0000, 0x0001, 0xFFFF, 0x0003,
249249
],
250250
),
251+
(
252+
"RepeatedReorderedAfterWrap",
253+
4,
254+
0xFFFF,
255+
vec![0x0, 0xFFFF, 0xFFFF],
256+
vec![true, true, true],
257+
vec![0x0, 0xFFFF],
258+
vec![0x0, 0xFFFF],
259+
),
251260
];
252261

253262
for (name, windows_size, max_seq, input, valid, expected, mut expected_wrap) in tests {

0 commit comments

Comments
 (0)