0006-Actually-fail-when-error-occurs-in-parseFormat.patch 1.4 KB

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