-
Notifications
You must be signed in to change notification settings - Fork 480
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 memory overflow and capacity regression. #727
Conversation
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.
Reviewed
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.
Followed clang-format rules
@mildsunrise could you take a look? |
thanks for the ping! looks okay to me. we're not affected though, right? |
@DrHazemAli I am not sure why the format still fails :( but changing to :
did fix it for me locally. Could you please update it one more time, thanks! |
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.
Updated
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.
clang-formatted.
@pabuhler It turned out that the issue is related to c-lang code formatting, can you give it a try? |
This reverts commit e16da02.
@DrHazemAli, not sure what happened but I reverted your last commit and fixed the formatting. If you are Ok with this then we can merge it. |
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 okay!
Reviewed ✅
@pabuhler I looked to your commit it looks good! |
Fix Memory Overflow and Capacity Regression in
srtp_stream_list_insert
This pull request addresses a critical issue in the
srtp_stream_list_insert
function where potential integer overflow and capacity regression could occur during memory allocation.Problem
The original code attempted to validate the multiplication of
sizeof(list_entry)
andnew_capacity
to check for overflow. However, this approach was flawed because the multiplication itself could overflow before the comparison, leading to undefined behavior.Solution
The fix ensures:
new_capacity
againstSIZE_MAX / sizeof(list_entry)
before performing the multiplication.new_capacity
does not regress below the current capacity, safeguarding against unintentional regressions.Updated Code
The following changes were made in the
srtp_stream_list_insert
function:Impact
new_capacity
always increases or remains valid, preventing capacity regression.Testing
srtp_stream_list_insert
without any regressions.Additional Notes