Commit 6d88d5ad authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

winealsa: Ensure that copy_format() will not write past end of

referenced WAVEFORMATPCMEX structure.
parent 59b2838f
......@@ -404,13 +404,20 @@ static BOOL supportedFormat(LPWAVEFORMATEX wf)
static void copy_format(LPWAVEFORMATEX wf1, LPWAVEFORMATPCMEX wf2)
{
unsigned int iLength;
ZeroMemory(wf2, sizeof(wf2));
if (wf1->wFormatTag == WAVE_FORMAT_PCM)
memcpy(wf2, wf1, sizeof(PCMWAVEFORMAT));
iLength = sizeof(PCMWAVEFORMAT);
else if (wf1->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
memcpy(wf2, wf1, sizeof(WAVEFORMATPCMEX));
iLength = sizeof(WAVEFORMATPCMEX);
else
memcpy(wf2, wf1, sizeof(WAVEFORMATEX) + wf1->cbSize);
iLength = sizeof(WAVEFORMATEX) + wf1->cbSize;
if (iLength > sizeof(WAVEFORMATPCMEX)) {
ERR("calculated %u bytes, capping to %u bytes\n", iLength, sizeof(WAVEFORMATPCMEX));
iLength = sizeof(WAVEFORMATPCMEX);
}
memcpy(wf2, wf1, iLength);
}
/*----------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment