From 083d8caee10892d2f3d9597609315231b6f8493a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 20 Oct 2016 23:43:26 +0200 Subject: QXbmHandler: fix missing NUL-termination The buffer is fed into strstr() on the next loop iteration, but strstr() expects a NUL-terminated string. In the equivalent code some lines up, the buffer is explicitly terminated, and we never write the last character of the buffer again, so we'll not fall off the end of the buffer, but if we read less bytes than in the last line, we'll parse garbage from the previous line. Change-Id: I354e1ce1dea71188942305190500b4778a69b4ff Reviewed-by: Edward Welbourne --- src/gui/image/qxbmhandler.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 44d07f1624..b21bc75bc4 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -157,6 +157,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage) } else { // read another line if ((readBytes = device->readLine(buf,buflen)) <= 0) // EOF ==> truncated image break; + buf[readBytes] = '\0'; p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x"); } } -- cgit v1.2.3