[PATCH] bmp image handler: check for out of range image size
authorEirik Aavitsland <eirik.aavitsland@qt.io>
Tue, 4 Sep 2018 09:08:06 +0000 (11:08 +0200)
committerRoberto C. Sánchez <roberto@debian.org>
Tue, 22 Aug 2023 13:42:24 +0000 (14:42 +0100)
Make the decoder fail early to avoid spending time and memory on
attempting to decode a corrupt image file.

Change-Id: I874e04f3b43122d73f8e58c7a5bcc4a741b68264
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Gbp-Pq: Name CVE-2018-19873.patch

src/gui/image/qbmphandler.cpp

index 078c59931bf1f503b5dc2a41a619a74c626510a6..cdbe03b6cc991650d04cf565972082f8a040040d 100644 (file)
@@ -181,6 +181,8 @@ static bool read_dib_infoheader(QDataStream &s, BMP_INFOHDR &bi)
     if (!(comp == BMP_RGB || (nbits == 4 && comp == BMP_RLE4) ||
         (nbits == 8 && comp == BMP_RLE8) || ((nbits == 16 || nbits == 32) && comp == BMP_BITFIELDS)))
          return false;                                // weird compression type
+    if (bi.biWidth < 0 || quint64(bi.biWidth) * qAbs(bi.biHeight) > 16384 * 16384)
+        return false;
 
     return true;
 }