qtgui-4.8.5-dont-crash-on-broken-GIF-images.patch 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. From f1b76c126c476c155af8c404b97c42cd1a709333 Mon Sep 17 00:00:00 2001
  2. From: Lars Knoll <lars.knoll@digia.com>
  3. Date: Thu, 24 Apr 2014 15:33:27 +0200
  4. Subject: Don't crash on broken GIF images
  5. Broken GIF images could set invalid width and height
  6. values inside the image, leading to Qt creating a null
  7. QImage for it. In that case we need to abort decoding
  8. the image and return an error.
  9. Initial patch by Rich Moore.
  10. Backport of Id82a4036f478bd6e49c402d6598f57e7e5bb5e1e from Qt 5
  11. Task-number: QTBUG-38367
  12. Change-Id: I0680740018aaa8356d267b7af3f01fac3697312a
  13. Security-advisory: CVE-2014-0190
  14. Reviewed-by: Richard J. Moore <rich@kde.org>
  15. ---
  16. src/gui/image/qgifhandler.cpp | 7 +++++++
  17. 1 file changed, 7 insertions(+)
  18. diff --git a/src/gui/image/qgifhandler.cpp b/src/gui/image/qgifhandler.cpp
  19. index 3324f04..5199dd3 100644
  20. --- a/src/gui/image/qgifhandler.cpp
  21. +++ b/src/gui/image/qgifhandler.cpp
  22. @@ -359,6 +359,13 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
  23. memset(bits, 0, image->byteCount());
  24. }
  25. + // Check if the previous attempt to create the image failed. If it
  26. + // did then the image is broken and we should give up.
  27. + if (image->isNull()) {
  28. + state = Error;
  29. + return -1;
  30. + }
  31. +
  32. disposePrevious(image);
  33. disposed = false;
  34. --
  35. 1.9.3