0003-Fixed-OOB-read-when-loading-invalid-ogg-flac-file.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. From 2c4ae870ec086f2ddd21a47861a3709c36faac45 Mon Sep 17 00:00:00 2001
  2. From: Scott Gayou <github.scott@gmail.com>
  3. Date: Tue, 9 Oct 2018 18:46:55 -0500
  4. Subject: [PATCH] Fixed OOB read when loading invalid ogg flac file. (#868)
  5. (#869)
  6. CVE-2018-11439 is caused by a failure to check the minimum length
  7. of a ogg flac header. This header is detailed in full at:
  8. https://xiph.org/flac/ogg_mapping.html. Added more strict checking
  9. for entire header.
  10. [Retrieved from:
  11. https://github.com/taglib/taglib/commit/2c4ae870ec086f2ddd21a47861a3709c36faac45]
  12. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  13. ---
  14. taglib/ogg/flac/oggflacfile.cpp | 14 ++++++++++++--
  15. 1 file changed, 12 insertions(+), 2 deletions(-)
  16. diff --git a/taglib/ogg/flac/oggflacfile.cpp b/taglib/ogg/flac/oggflacfile.cpp
  17. index 53d04508a..07ea9dccc 100644
  18. --- a/taglib/ogg/flac/oggflacfile.cpp
  19. +++ b/taglib/ogg/flac/oggflacfile.cpp
  20. @@ -231,11 +231,21 @@ void Ogg::FLAC::File::scan()
  21. if(!metadataHeader.startsWith("fLaC")) {
  22. // FLAC 1.1.2+
  23. + // See https://xiph.org/flac/ogg_mapping.html for the header specification.
  24. + if(metadataHeader.size() < 13)
  25. + return;
  26. +
  27. + if(metadataHeader[0] != 0x7f)
  28. + return;
  29. +
  30. if(metadataHeader.mid(1, 4) != "FLAC")
  31. return;
  32. - if(metadataHeader[5] != 1)
  33. - return; // not version 1
  34. + if(metadataHeader[5] != 1 && metadataHeader[6] != 0)
  35. + return; // not version 1.0
  36. +
  37. + if(metadataHeader.mid(9, 4) != "fLaC")
  38. + return;
  39. metadataHeader = metadataHeader.mid(13);
  40. }