-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Fix #4815 by adjusting length n
before checking overflow
#4816
Fix #4815 by adjusting length n
before checking overflow
#4816
Conversation
n
before checking overflown
before checking overflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
The failed tests seem like a "bug" with the It uses a One workaround is to add a positive 9 when setting the |
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
We might want to consider waiting until the next breaking release of tokio-util. We are not going to make a release that breaks hyper. |
I'm closing this for now. I'll reopen it when we make the tokio-util breaking release. |
Motivation
This is to solve the issue #4815, which finds that the encoded bytes of a max-sized frame with a negative-valued length adjustment cannot be decoded with the codec.
Solution
The problem is caused by checking overflow before making length adjustment to the decoded length
n
(#4815 (comment)). This PR simply reverses the order (ie. it now makes adjustment to the lengthn
before checking overflow).A new unit test
read_single_frame_negative_length_adjusted_and_max_sized
has been added totokio-util/tests/length_delimited.rs
to test this scenario.