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.

50 lines
1.6 KiB

  1. From 2240fbf5912054af025fb6e01e26375100275e74 Mon Sep 17 00:00:00 2001
  2. From: Nick Wellnhofer <wellnhofer@aevum.de>
  3. Date: Mon, 30 Jul 2018 13:14:11 +0200
  4. Subject: [PATCH 13/13] Fix infinite loop in LZMA decompression
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. Check the liblzma error code more thoroughly to avoid infinite loops.
  9. Closes: https://gitlab.gnome.org/GNOME/libxml2/issues/13
  10. Closes: https://bugzilla.gnome.org/show_bug.cgi?id=794914
  11. This is CVE-2018-9251 and CVE-2018-14567.
  12. Thanks to Dongliang Mu and Simon Wörner for the reports.
  13. ---
  14. xzlib.c | 9 +++++++++
  15. 1 file changed, 9 insertions(+)
  16. diff --git a/xzlib.c b/xzlib.c
  17. index a839169e..0ba88cfa 100644
  18. --- a/xzlib.c
  19. +++ b/xzlib.c
  20. @@ -562,6 +562,10 @@ xz_decomp(xz_statep state)
  21. "internal error: inflate stream corrupt");
  22. return -1;
  23. }
  24. + /*
  25. + * FIXME: Remapping a couple of error codes and falling through
  26. + * to the LZMA error handling looks fragile.
  27. + */
  28. if (ret == Z_MEM_ERROR)
  29. ret = LZMA_MEM_ERROR;
  30. if (ret == Z_DATA_ERROR)
  31. @@ -587,6 +591,11 @@ xz_decomp(xz_statep state)
  32. xz_error(state, LZMA_PROG_ERROR, "compression error");
  33. return -1;
  34. }
  35. + if ((state->how != GZIP) &&
  36. + (ret != LZMA_OK) && (ret != LZMA_STREAM_END)) {
  37. + xz_error(state, ret, "lzma error");
  38. + return -1;
  39. + }
  40. } while (strm->avail_out && ret != LZMA_STREAM_END);
  41. /* update available output and crc check value */
  42. --
  43. 2.18.0