mirror of
https://github.com/azahar-emu/soundtouch
synced 2025-11-07 07:30:02 +01:00
Fixed WavFile header/fact not-too-small check
This commit is contained in:
parent
c38f0506da
commit
e024068905
@ -518,14 +518,14 @@ int WavInFile::readHeaderBlock()
|
|||||||
// swap byte order if necessary
|
// swap byte order if necessary
|
||||||
_swap32(nLen);
|
_swap32(nLen);
|
||||||
|
|
||||||
// verify that header length isn't smaller than expected
|
// calculate how much length differs from expected
|
||||||
if (nLen < sizeof(header.format) - 8) return -1;
|
nDump = nLen - ((int)sizeof(header.format) - 8);
|
||||||
|
|
||||||
|
// verify that header length isn't smaller than expected structure
|
||||||
|
if (nDump < 0) return -1;
|
||||||
|
|
||||||
header.format.format_len = nLen;
|
header.format.format_len = nLen;
|
||||||
|
|
||||||
// calculate how much length differs from expected
|
|
||||||
nDump = nLen - ((int)sizeof(header.format) - 8);
|
|
||||||
|
|
||||||
// if format_len is larger than expected, read only as much data as we've space for
|
// if format_len is larger than expected, read only as much data as we've space for
|
||||||
if (nDump > 0)
|
if (nDump > 0)
|
||||||
{
|
{
|
||||||
@ -561,16 +561,16 @@ int WavInFile::readHeaderBlock()
|
|||||||
// read length of the fact field
|
// read length of the fact field
|
||||||
if (fread(&nLen, sizeof(int), 1, fptr) != 1) return -1;
|
if (fread(&nLen, sizeof(int), 1, fptr) != 1) return -1;
|
||||||
// swap byte order if necessary
|
// swap byte order if necessary
|
||||||
_swap32(nLen); // int fact_len;
|
_swap32(nLen);
|
||||||
|
|
||||||
// verify that fact length isn't smaller than expected
|
|
||||||
if (nLen < sizeof(header.fact) - 8) return -1;
|
|
||||||
|
|
||||||
header.fact.fact_len = nLen;
|
|
||||||
|
|
||||||
// calculate how much length differs from expected
|
// calculate how much length differs from expected
|
||||||
nDump = nLen - ((int)sizeof(header.fact) - 8);
|
nDump = nLen - ((int)sizeof(header.fact) - 8);
|
||||||
|
|
||||||
|
// verify that fact length isn't smaller than expected structure
|
||||||
|
if (nDump < 0) return -1;
|
||||||
|
|
||||||
|
header.fact.fact_len = nLen;
|
||||||
|
|
||||||
// if format_len is larger than expected, read only as much data as we've space for
|
// if format_len is larger than expected, read only as much data as we've space for
|
||||||
if (nDump > 0)
|
if (nDump > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user