09_Actually-fail-when-error-occurs-in-parseFormat.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From: Antonio Larrosa <larrosa@kde.org>
  2. Date: Mon, 6 Mar 2017 18:59:26 +0100
  3. Subject: Actually fail when error occurs in parseFormat
  4. When there's an unsupported number of bits per sample or an invalid
  5. number of samples per block, don't only print an error message using
  6. the error handler, but actually stop parsing the file.
  7. This fixes #35 (also reported at
  8. https://bugzilla.opensuse.org/show_bug.cgi?id=1026983 and
  9. https://blogs.gentoo.org/ago/2017/02/20/audiofile-heap-based-buffer-overflow-in-imadecodeblockwave-ima-cpp/
  10. )
  11. ---
  12. libaudiofile/WAVE.cpp | 2 ++
  13. 1 file changed, 2 insertions(+)
  14. diff --git a/libaudiofile/WAVE.cpp b/libaudiofile/WAVE.cpp
  15. index 0fc48e8..d04b796 100644
  16. --- a/libaudiofile/WAVE.cpp
  17. +++ b/libaudiofile/WAVE.cpp
  18. @@ -332,6 +332,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
  19. {
  20. _af_error(AF_BAD_NOT_IMPLEMENTED,
  21. "IMA ADPCM compression supports only 4 bits per sample");
  22. + return AF_FAIL;
  23. }
  24. int bytesPerBlock = (samplesPerBlock + 14) / 8 * 4 * channelCount;
  25. @@ -339,6 +340,7 @@ status WAVEFile::parseFormat(const Tag &id, uint32_t size)
  26. {
  27. _af_error(AF_BAD_CODEC_CONFIG,
  28. "Invalid samples per block for IMA ADPCM compression");
  29. + return AF_FAIL;
  30. }
  31. track->f.sampleWidth = 16;