New take on CVE-2018-17097 i.e. avoiding writing beyond end of buffer in case of 24-bit samples

This commit is contained in:
Olli 2018-10-31 18:36:05 +02:00
parent 6d700259b9
commit 7f594f8b7d

View File

@ -924,8 +924,7 @@ void WavOutFile::write(const float *buffer, int numElems)
bytesPerSample = header.format.bits_per_sample / 8;
numBytes = numElems * bytesPerSample;
int confBufBytes = (numBytes + 3) & -4; // round up to nearest multiple of four to avoid overflow with 24bit-value assignment
void *temp = getConvBuffer(confBufBytes);
void *temp = getConvBuffer(numBytes + 7); // round bit up to avoid buffer overrun with 24bit-value assignment
switch (bytesPerSample)
{