Fixed crash in image reader when reading certain BMP files.
If the high bit in a mask is set, for instance if the mask is 0xff000000, and we shift it to the right by 24 positions, since the mask was not declared as unsigned we ended up with a mask value of 0xffffffff. We then add 1 to this value and divide by the result, causing a division by zero crash. The masks need to be declared unsigned to prevent sign bit extension when shifting right. Task-number: QTBUG-29194 Change-Id: I79260344cebfbdd3ea86416a9c734dca76517999 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>bb10
parent
c3ae1c76f3
commit
af84313c62
|
|
@ -143,7 +143,7 @@ static QDataStream &operator<<(QDataStream &s, const BMP_INFOHDR &bi)
|
|||
return s;
|
||||
}
|
||||
|
||||
static int calc_shift(int mask)
|
||||
static int calc_shift(uint mask)
|
||||
{
|
||||
int result = 0;
|
||||
while (mask && !(mask & 1)) {
|
||||
|
|
@ -207,9 +207,9 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
|
|||
#endif
|
||||
int w = bi.biWidth, h = bi.biHeight, nbits = bi.biBitCount;
|
||||
int t = bi.biSize, comp = bi.biCompression;
|
||||
int red_mask = 0;
|
||||
int green_mask = 0;
|
||||
int blue_mask = 0;
|
||||
uint red_mask = 0;
|
||||
uint green_mask = 0;
|
||||
uint blue_mask = 0;
|
||||
int red_shift = 0;
|
||||
int green_shift = 0;
|
||||
int blue_shift = 0;
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
|
|
@ -34,6 +34,7 @@
|
|||
<file>images/noclearcode.bmp</file>
|
||||
<file>images/noclearcode.gif</file>
|
||||
<file>images/nontransparent.xpm</file>
|
||||
<file>images/rgb32bf.bmp</file>
|
||||
<file>images/runners.ppm</file>
|
||||
<file>images/teapot.ppm</file>
|
||||
<file>images/test.ppm</file>
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ void tst_QImageReader::readImage_data()
|
|||
QTest::newRow("BMP: 4bpp uncompressed") << QString("tst7.bmp") << true << QByteArray("bmp");
|
||||
QTest::newRow("BMP: 16bpp") << QString("16bpp.bmp") << true << QByteArray("bmp");
|
||||
QTest::newRow("BMP: negative height") << QString("negativeheight.bmp") << true << QByteArray("bmp");
|
||||
QTest::newRow("BMP: high mask bit set") << QString("rgb32bf.bmp") << true << QByteArray("bmp");
|
||||
QTest::newRow("XPM: marble") << QString("marble.xpm") << true << QByteArray("xpm");
|
||||
QTest::newRow("PNG: kollada") << QString("kollada.png") << true << QByteArray("png");
|
||||
QTest::newRow("PPM: teapot") << QString("teapot.ppm") << true << QByteArray("ppm");
|
||||
|
|
|
|||
Loading…
Reference in New Issue