From b4ed054e2f6b4c460f64c33b61b8800dc78f9e6d Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 18 Aug 2015 14:06:07 +0200 Subject: [PATCH] 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 --- src/gui/image/qppmhandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; ypeek(&buf, 1) == 1); y++) { p = outImage->scanLine(y); n = pbm_bpl; if (nbits == 1) {