PPM image format: avoid useless processing on truncated files

For ascii formatted files, the handler would not stop processing on a
premature EOF, but instead continue to fill the whole image memory
area byte by byte. This could lead to unexpected CPU exhaustion in the
case of a small image file declaring huge image dimensions, but having
no content.

Instead, check for EOF for each scanline and quit processing if found.

Change-Id: I8dbcd7eb34553873e49706d61b5752f22e04eb6a
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
bb10
Eirik Aavitsland 2015-08-18 14:06:07 +02:00 committed by aavit
parent fee16baca1
commit b4ed054e2f
1 changed files with 2 additions and 1 deletions

View File

@ -182,7 +182,8 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
} else { // read ascii data
uchar *p;
int n;
for (y=0; y<h; y++) {
char buf;
for (y = 0; (y < h) && (device->peek(&buf, 1) == 1); y++) {
p = outImage->scanLine(y);
n = pbm_bpl;
if (nbits == 1) {