Fix an indexing panic in compression#578
Merged
seanmonstar merged 1 commit intotower-rs:mainfrom Jun 3, 2025
Merged
Conversation
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.
df86aed to
43d704f
Compare
Member
|
@seanmonstar Could you yank the latest version and release a new one? (for some reason the crates.io web interface doesn't offer me the Yank button) |
Contributor
|
You might want to add some tests first? and perhaps have it as a policy to at least have some tests. Even better if you can reuse this from a utility module or w/e. As that would have prevented the original mistake to begin with. |
Member
|
I'm swamped with staying on top of things already, so I don't have any spare time to write tests. A PR with tests would be very welcome though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
I'm happy to contribute a test or two as well, if so desired.