summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-10-20 23:43:26 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-11-15 16:50:42 +0000
commit083d8caee10892d2f3d9597609315231b6f8493a (patch)
treedb90e9651466ebe0226ad07d748510446c2cb7c9 /src
parentf2205c48c21a6b135f2f59d0cf46e72f90f9f0f4 (diff)
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 <edward.welbourne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/gui/image/qxbmhandler.cpp1
1 files changed, 1 insertions, 0 deletions
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");
}
}