Lines 1-53
Link Here
|
1 |
commit 3e55cd6dc467303a3c35312e9fcb255c2c048b32 |
|
|
2 |
Author: Eirik Aavitsland <eirik.aavitsland@theqtcompany.com> |
3 |
Date: Wed Mar 11 13:34:01 2015 +0100 |
4 |
|
5 |
Fixes crash in bmp and ico image decoding |
6 |
|
7 |
Fuzzing test revealed that for certain malformed bmp and ico files, |
8 |
the handler would segfault. |
9 |
|
10 |
Change-Id: I19d45145f31e7f808f7f6a1a1610270ea4159cbe |
11 |
(cherry picked from qtbase/2adbbae5432aa9d8cc41c6fcf55c2e310d2d4078) |
12 |
Reviewed-by: Richard J. Moore <rich@kde.org> |
13 |
|
14 |
--- src/gui/image/qbmphandler.cpp |
15 |
+++ src/gui/image/qbmphandler.cpp |
16 |
@@ -478,12 +478,6 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int |
17 |
p = data + (h-y-1)*bpl; |
18 |
break; |
19 |
case 2: // delta (jump) |
20 |
- // Protection |
21 |
- if ((uint)x >= (uint)w) |
22 |
- x = w-1; |
23 |
- if ((uint)y >= (uint)h) |
24 |
- y = h-1; |
25 |
- |
26 |
{ |
27 |
quint8 tmp; |
28 |
d->getChar((char *)&tmp); |
29 |
@@ -491,6 +485,13 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int |
30 |
d->getChar((char *)&tmp); |
31 |
y += tmp; |
32 |
} |
33 |
+ |
34 |
+ // Protection |
35 |
+ if ((uint)x >= (uint)w) |
36 |
+ x = w-1; |
37 |
+ if ((uint)y >= (uint)h) |
38 |
+ y = h-1; |
39 |
+ |
40 |
p = data + (h-y-1)*bpl + x; |
41 |
break; |
42 |
default: // absolute mode |
43 |
--- src/plugins/imageformats/ico/qicohandler.cpp |
44 |
+++ src/plugins/imageformats/ico/qicohandler.cpp |
45 |
@@ -571,7 +571,7 @@ QImage ICOReader::iconAt(int index) |
46 |
QImage::Format format = QImage::Format_ARGB32; |
47 |
if (icoAttrib.nbits == 24) |
48 |
format = QImage::Format_RGB32; |
49 |
- else if (icoAttrib.ncolors == 2) |
50 |
+ else if (icoAttrib.ncolors == 2 && icoAttrib.depth == 1) |
51 |
format = QImage::Format_Mono; |
52 |
else if (icoAttrib.ncolors > 0) |
53 |
format = QImage::Format_Indexed8; |