mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 06:28:19 +00:00
Fix potential out-of-bounds writes on invalid opus files
The third parameter of the `op_read` function specifies the remaining size of the buffer, but we always passed the total size of the buffer without respecting the position at which the data is written into the buffer.
This commit is contained in:
parent
4d37775c17
commit
51012bcc1b
|
@ -358,7 +358,7 @@ bool CSound::DecodeOpus(CSample &Sample, const void *pData, unsigned DataSize) c
|
|||
int Pos = 0;
|
||||
while(Pos < NumSamples)
|
||||
{
|
||||
const int Read = op_read(pOpusFile, pSampleData + Pos * NumChannels, NumSamples * NumChannels, nullptr);
|
||||
const int Read = op_read(pOpusFile, pSampleData + Pos * NumChannels, (NumSamples - Pos) * NumChannels, nullptr);
|
||||
if(Read < 0)
|
||||
{
|
||||
free(pSampleData);
|
||||
|
|
Loading…
Reference in a new issue