-
Notifications
You must be signed in to change notification settings - Fork 54
Fixes to use the same buffer as input and output #320
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #320 +/- ##
==========================================
+ Coverage 80.56% 80.62% +0.06%
==========================================
Files 18 18
Lines 1662 1683 +21
==========================================
+ Hits 1339 1357 +18
- Misses 221 223 +2
- Partials 102 103 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Added checks for the same buffer to stop copying data when not needed. Also fixed srtpCipherAesCmHmacSha1 to work with one buffer when encrypting and decrypting RTCP packets.
4227879
to
a50d986
Compare
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.
LGTM
@@ -59,9 +63,7 @@ func (c *Context) decryptRTCP(dst, encrypted []byte) ([]byte, error) { | |||
} | |||
} | |||
|
|||
out := allocateIfMismatch(dst, encrypted) |
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.
note: allocateIfMismatch
handled nil dst
but growBuffer
in cipher.decryptRTCP
also handles nil output buffer
sameBuffer := isSameBuffer(dst, encrypted) | ||
|
||
if !sameBuffer { | ||
copy(dst, encrypted[:srtcpHeaderSize]) // Copy the first 8 bytes (RTCP header) |
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 like the original code didn't do this?
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.
allocateIfMismatch
seems to have copied the buffer.
Fixed code is nice👍
Added checks for the same buffer to stop copying data when not needed. Also fixed srtpCipherAesCmHmacSha1 to work with one buffer when encrypting and decrypting RTCP packets.