05_Always-check-the-number-of-coefficients.patch 947 B

12345678910111213141516171819202122232425262728293031
  1. From: Antonio Larrosa <larrosa@kde.org>
  2. Date: Mon, 6 Mar 2017 12:51:22 +0100
  3. Subject: Always check the number of coefficients
  4. When building the library with NDEBUG, asserts are eliminated
  5. so it's better to always check that the number of coefficients
  6. is inside the array range.
  7. This fixes the 00191-audiofile-indexoob issue in #41
  8. ---
  9. libaudiofile/WAVE.cpp | 6 ++++++
  10. 1 file changed, 6 insertions(+)
  11. diff --git a/libaudiofile/WAVE.cpp b/libaudiofile/WAVE.cpp
  12. index 9dd8511..0fc48e8 100644
  13. --- a/libaudiofile/WAVE.cpp
  14. +++ b/libaudiofile/WAVE.cpp
  15. @@ -281,6 +281,12 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
  16. /* numCoefficients should be at least 7. */
  17. assert(numCoefficients >= 7 && numCoefficients <= 255);
  18. + if (numCoefficients < 7 || numCoefficients > 255)
  19. + {
  20. + _af_error(AF_BAD_HEADER,
  21. + "Bad number of coefficients");
  22. + return AF_FAIL;
  23. + }
  24. m_msadpcmNumCoefficients = numCoefficients;