summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorRichard J. Moore <rich@kde.org>2015-02-24 19:02:35 (GMT)
committerRichard J. Moore <rich@kde.org>2015-02-26 22:32:51 (GMT)
commite50aa2252cdd5cb53eef7d8c4503c7edff634f68 (patch)
tree78a27cca224e7cf78fca698548a326343497630c /src/gui
parent7296f653afe717118fc8533f0a72e3fb77fc42d8 (diff)
downloadQt-e50aa2252cdd5cb53eef7d8c4503c7edff634f68.zip
Qt-e50aa2252cdd5cb53eef7d8c4503c7edff634f68.tar.gz
Qt-e50aa2252cdd5cb53eef7d8c4503c7edff634f68.tar.bz2
Fix a division by zero when processing malformed BMP files.
This fixes a division by 0 when processing a maliciously crafted BMP file. No impact beyond DoS. Backport of 661f6bfd032dacc62841037732816a583640e187 Task-number: QTBUG-44547 Change-Id: I43f06e752b11cb50669101460902a82b885ae618 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qbmphandler.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp
index b22e842..30fa9e0 100644
--- a/src/gui/image/qbmphandler.cpp
+++ b/src/gui/image/qbmphandler.cpp
@@ -319,10 +319,16 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
}
} else if (comp == BMP_BITFIELDS && (nbits == 16 || nbits == 32)) {
red_shift = calc_shift(red_mask);
+ if (((red_mask >> red_shift) + 1) == 0)
+ return false;
red_scale = 256 / ((red_mask >> red_shift) + 1);
green_shift = calc_shift(green_mask);
+ if (((green_mask >> green_shift) + 1) == 0)
+ return false;
green_scale = 256 / ((green_mask >> green_shift) + 1);
blue_shift = calc_shift(blue_mask);
+ if (((blue_mask >> blue_shift) + 1) == 0)
+ return false;
blue_scale = 256 / ((blue_mask >> blue_shift) + 1);
} else if (comp == BMP_RGB && (nbits == 24 || nbits == 32)) {
blue_mask = 0x000000ff;