[wvdecrypter] Fix memory heap corruption #1346
Merged
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.
Description
After PR #1310 when you play a Widevine encrypted content on a debug build kodi crash with a memory heap corruption
the reason seem to be on changed code that looks bad and unsafe,
the code take the mem pointer from data_out and store to packet_out, this to manually copy data by using
memcpy
seem to avoid use the bento4 object methodAppendData
the size of buffer internally of the data_out object is assumed to be big enough to contains written data, but if not so?
weird thing can happens also because at the end is called
data_out.SetDataSize
to update the wrong object data size,from what i understand SetDataSize not only update the container data size but can also reallocate the object buffer,
if this happens the reallocation copy the buffer data but based on initial data size and not on what we have written with
memcpy
, that could exceed the size...I do not know if I have explained myself correctly anyway dont crash anymore
maybe in the past has been done so to try limit
SetDataSize
uses in thewhile (packet_in < packet_in_e)
loop, at least with h264 i get at max 4 loops only not big thingsa test confermation would be appreciated
How has this been tested?
played n€tflix on windows, debug build
played n€tflix on android, but release build
Screenshots (if appropriate):
Types of change
Checklist: