Skip to content

Commit

Permalink
Merge pull request #35 from tigeli/vulns
Browse files Browse the repository at this point in the history
  • Loading branch information
sletta committed Apr 13, 2015
2 parents 874c430 + 2432e40 commit d87abe9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/gui/image/qbmphandler.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -472,19 +478,20 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, int offset, int
p = data + (h-y-1)*bpl;
break;
case 2: // delta (jump)
// Protection
if ((uint)x >= (uint)w)
x = w-1;
if ((uint)y >= (uint)h)
y = h-1;

{
quint8 tmp;
d->getChar((char *)&tmp);
x += tmp;
d->getChar((char *)&tmp);
y += tmp;
}

// Protection
if ((uint)x >= (uint)w)
x = w-1;
if ((uint)y >= (uint)h)
y = h-1;

p = data + (h-y-1)*bpl + x;
break;
default: // absolute mode
Expand Down
9 changes: 9 additions & 0 deletions src/gui/image/qgifhandler.cpp
Expand Up @@ -359,6 +359,13 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
memset(bits, 0, image->byteCount());
}

// Check if the previous attempt to create the image failed. If it
// did then the image is broken and we should give up.
if (image->isNull()) {
state = Error;
return -1;
}

disposePrevious(image);
disposed = false;

Expand Down Expand Up @@ -937,6 +944,8 @@ void QGIFFormat::fillRect(QImage *image, int col, int row, int w, int h, QRgb co

void QGIFFormat::nextY(unsigned char *bits, int bpl)
{
if (out_of_bounds)
return;
int my;
switch (interlace) {
case 0: // Non-interlaced
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/imageformats/ico/qicohandler.cpp
Expand Up @@ -571,7 +571,7 @@ QImage ICOReader::iconAt(int index)
QImage::Format format = QImage::Format_ARGB32;
if (icoAttrib.nbits == 24)
format = QImage::Format_RGB32;
else if (icoAttrib.ncolors == 2)
else if (icoAttrib.ncolors == 2 && icoAttrib.depth == 1)
format = QImage::Format_Mono;
else if (icoAttrib.ncolors > 0)
format = QImage::Format_Indexed8;
Expand Down

0 comments on commit d87abe9

Please sign in to comment.