Skip to content

Commit 9f04e7b

Browse files
fix: verify suffix range ends at file boundary in matches_requested_range
The suffix match only checked that the range length equaled the requested suffix, but did not verify the range ends at the file boundary. When size is known, also check `range.end() + 1 == size`.
1 parent 1f3be60 commit 9f04e7b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/headers/content_range.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ impl HttpContentRange {
3131
HttpRange::Range(OrderedRange { start, end }),
3232
HttpContentRange::Bound(Bound { range, .. }),
3333
) => start == range.start() && end == range.end(),
34-
(HttpRange::Suffix(suffix), HttpContentRange::Bound(Bound { range, .. })) => {
35-
(range.end() - range.start()).checked_add(1) == Some(suffix)
34+
(HttpRange::Suffix(suffix), HttpContentRange::Bound(Bound { range, size })) => {
35+
let length_matches = (range.end() - range.start()).checked_add(1) == Some(suffix);
36+
let ends_at_boundary = size.is_none_or(|size| range.end() + 1 == size);
37+
length_matches && ends_at_boundary
3638
}
3739
(
3840
HttpRange::StartingPoint(n),

0 commit comments

Comments
 (0)