mirror of https://github.com/n64decomp/sm64.git
Fix security vulnerability: add bounds check for numCoefficients
When building with NDEBUG, asserts are eliminated, which could lead to buffer overflow via out-of-bounds access to m_msadpcmCoefficients. This adds explicit bounds checks that remain even when assertions are disabled. Similar to the fix for CVE-2018-13440 in the original AudioFile library.
This commit is contained in:
parent
9921382a68
commit
7dd0f121e4
|
|
@ -11183,7 +11183,11 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
|
|||
|
||||
/* numCoefficients should be at least 7. */
|
||||
assert(numCoefficients >= 7 && numCoefficients <= 255);
|
||||
|
||||
if (numCoefficients < 7 || numCoefficients > 255)
|
||||
{
|
||||
_af_error(AF_BAD_HEADER, "Bad number of coefficients");
|
||||
return AF_FAIL;
|
||||
}
|
||||
m_msadpcmNumCoefficients = numCoefficients;
|
||||
|
||||
for (int i=0; i<m_msadpcmNumCoefficients; i++)
|
||||
|
|
|
|||
Loading…
Reference in New Issue