- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bytes::peek_ahead is unsound #186
Comments
Hm, that does seem true. I'll just note that a search of the method shows it's only ever used correctly. Actually, it's only used once, to check for the 5th byte after comparing the previous 4. That usage could probably be touched up... Though I recognize that match was very specifically tuned to improve performance... |
Right, there is only a single use as you noted, here: Lines 843 to 867 in 97c7e6e
and the computed pointer is at most one element past the end of the |
If
n
is large enough to cause wrapping thenself.cursor.wrapping_add(n)
would likely be less than self.start. Either saturating_add is needed, or a test thatn < end - cursor
.https://github.com/seanmonstar/httparse/blob/master/src/iter.rs#L44-L55
Edit: actually saturating_add does not (yet?) exist for pointer arithmetic
The text was updated successfully, but these errors were encountered: