summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@qt.io>2018-09-04 11:08:06 +0200
committerLiang Qi <liang.qi@qt.io>2018-09-24 21:01:50 +0000
commit5104a529ce5aea5e94101770ece188b98f20baaa (patch)
treeb412651ad7513f43b1abae135c89eb402377c10c
parent9f95f25d2ef3de76d449bc4de5b09e87e9ed537a (diff)
bmp image handler: check for out of range image size
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> (cherry picked from commit 621ab8ab59901cc3f9bd98be709929c9eac997a8) Reviewed-by: Liang Qi <liang.qi@qt.io>
-rw-r--r--src/gui/image/qbmphandler.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index 703c5c0f31..6990d69b35 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -188,6 +188,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;
}