Add format sub-chunk size check to WAV parsing
This fixes a crash due to reading beyond the buffer bounds when checking for "data" if WAVEFORMAT::uiSize was too big.
This commit is contained in:
parent
69cd6039eb
commit
45e8d13e13
@ -657,6 +657,12 @@ bool wxSound::LoadWAV(const void* data_, size_t length, bool copyData)
|
||||
return false;
|
||||
if (memcmp(&data[FMT_INDEX], "fmt ", 4) != 0)
|
||||
return false;
|
||||
|
||||
// Check that the format chunk size is correct: it must be 16 for PCM,
|
||||
// which is the only format we handle.
|
||||
if (waveformat.uiSize != 16)
|
||||
return false;
|
||||
|
||||
if (memcmp(&data[FMT_INDEX + waveformat.uiSize + 8], "data", 4) != 0)
|
||||
return false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user