Fix: Twcc wraparound uint16 promotion case #2101
Open
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.
Issue #, if available:
What was changed?
PeerConnection.c
: Added type casting to prevent integer promotion issues when handling sequence number wraparound in the twccRollingWindowDeletion function.Rtcp.c
: Added type casting to prevent integer promotion issues when handling sequence number wraparound in the updateTwccHashTable function.RtcpFunctionalityTest.cpp
: Added a new test case to validate the behavior of sequence number handling when integer promotion occurs due to UINT16_MAX.Why was it changed?
lastReportedSeqNum
is exactlyUINT16_MAX
, the subsequent increment can cause incorrect behavior due to promotion to a larger integer type.lastReportedSeqNum
is at the value ofUINT16_MAX
.How was it changed?
PeerConnection.c
andRtcp.c
, explicit casting toUINT16
was added to the sequence number comparisons to prevent unintentional integer promotion to a larger type.lastReportedSeqNum
+ 1) can be promoted to a larger integer type, the explicit casting ensures that the result remains within the bounds of UINT16, effectively voiding the promotion.RtcpFunctionalityTest.cpp
, a new test was added to simulate the case wherelastReportedSeqNum
isUINT16_MAX
and ensure that the integer promotion does not cause any issues when updating the hash table.What testing was done for the changes?
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.