summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEirik Aavitsland <eirik.aavitsland@theqtcompany.com>2015-08-18 14:06:07 +0200
committeraavit <eirik.aavitsland@theqtcompany.com>2015-09-01 08:21:53 +0000
commitb4ed054e2f6b4c460f64c33b61b8800dc78f9e6d (patch)
tree9c42c18de9b8c11dbe29938f3214536c2c18a019 /src
parentfee16baca1e1db441c1d95952373aa324f704990 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/gui/image/qppmhandler.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp
index 0f4256b740..f460431c2b 100644
--- a/src/gui/image/qppmhandler.cpp
+++ b/src/gui/image/qppmhandler.cpp
@@ -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) {