Skip to content

Commit 359d997

Browse files
authored
Fix an indexing panic in compression (#578)
This guard was backwards, not only breaking the functionality it was intended to provide, but also causing panics under certain conditions. In this case, the haystack is the pre-existing Vary header on the response, and the needle is "Accept-Econding". If we are compressing a response, and there is already a Vary header on the response, it is <= 15 bytes and does not match Accept-Encoding, this would cause a range index error as the while statement would not provide an effective guard.
1 parent 24c0f0b commit 359d997

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tower-http/src/compression/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ where
122122
}
123123

124124
fn contains_ignore_ascii_case(mut haystack: &[u8], needle: &[u8]) -> bool {
125-
while haystack.len() <= needle.len() {
125+
while needle.len() <= haystack.len() {
126126
if haystack[..needle.len()].eq_ignore_ascii_case(needle) {
127127
return true;
128128
}

0 commit comments

Comments
 (0)