fix(s2n-quic-core): enforce max data limit size for stream and connection #1693
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.
Resolved issues:
#1675
Description of changes:
Limits::with_data_window accepts a u64 and is a limit specified by our users. In the
debug
build, we currently enforce that max_data limit is <= u32::MAX with a debug_assert. In therelease
build, the debug_assert is compiled out and applications can erroneously provide a value larger than u32::MAX.This PR adds validation to the Limits builder which checks the value is less than u32 and provides a better user error. I also added comments on why its reasonable to restrict the value to u32 in this case. Finally, I convert the debug_asset into an assert to ensure we do no accidentally revert this change and re-introduce the bug only for the release build.
Call-outs:
Note that is issue actually applies to 4 data limits:
Note that the limits are backed by a IncrementalValueSync which will periodically update a bigger value to the remote endpoint so restricting the initial value to u32 is not a loss of functionality.
Testing:
482s s2n_quic:server:conn: packet_header=OneRtt { number: 28672209 } frame=Stream { id: 0, offset: 40294967189 } ...
Is this a refactor change? If so, how have you proved that the intended behavior hasn't changed? -->
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.