You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.3 KiB

  1. From 25eb00ce913452c2e614548d7df93070bf0d066f Mon Sep 17 00:00:00 2001
  2. From: Antonio Larrosa <larrosa@kde.org>
  3. Date: Mon, 6 Mar 2017 18:02:31 +0100
  4. Subject: [PATCH] clamp index values to fix index overflow in IMA.cpp
  5. This fixes #33
  6. (also reported at https://bugzilla.opensuse.org/show_bug.cgi?id=1026981
  7. and https://blogs.gentoo.org/ago/2017/02/20/audiofile-global-buffer-overflow-in-decodesample-ima-cpp/)
  8. ---
  9. libaudiofile/modules/IMA.cpp | 4 ++--
  10. 1 file changed, 2 insertions(+), 2 deletions(-)
  11. diff --git a/libaudiofile/modules/IMA.cpp b/libaudiofile/modules/IMA.cpp
  12. index 7476d44..df4aad6 100644
  13. --- a/libaudiofile/modules/IMA.cpp
  14. +++ b/libaudiofile/modules/IMA.cpp
  15. @@ -169,7 +169,7 @@ int IMA::decodeBlockWAVE(const uint8_t *encoded, int16_t *decoded)
  16. if (encoded[1] & 0x80)
  17. m_adpcmState[c].previousValue -= 0x10000;
  18. - m_adpcmState[c].index = encoded[2];
  19. + m_adpcmState[c].index = clamp(encoded[2], 0, 88);
  20. *decoded++ = m_adpcmState[c].previousValue;
  21. @@ -210,7 +210,7 @@ int IMA::decodeBlockQT(const uint8_t *encoded, int16_t *decoded)
  22. predictor -= 0x10000;
  23. state.previousValue = clamp(predictor, MIN_INT16, MAX_INT16);
  24. - state.index = encoded[1] & 0x7f;
  25. + state.index = clamp(encoded[1] & 0x7f, 0, 88);
  26. encoded += 2;
  27. for (int n=0; n<m_framesPerPacket; n+=2)
  28. --
  29. 2.11.0