From 8c9180190ae6d87d7a3f294bc942b6db3f3ebb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 5 Jan 2020 00:50:02 +0100 Subject: [PATCH] Fixed buffer overflow --- src/data/gpiparser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/data/gpiparser.cpp b/src/data/gpiparser.cpp index a65a6702..2a9ab74e 100644 --- a/src/data/gpiparser.cpp +++ b/src/data/gpiparser.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -169,15 +170,16 @@ static quint32 readTranslatedObjects(QDataStream &stream, QTextCodec *codec, QList &objects) { qint32 size = 0, ret; - char lang[2]; + char lang[3]; + memset(lang, 0, sizeof(lang)); objects.clear(); stream >> size; ret = size + 4; while (stream.status() == QDataStream::Ok && size > 0) { QString str; - stream.readRawData(lang, sizeof(lang)); + stream.readRawData(lang, sizeof(lang) - 1); size -= readString(stream, codec, str) + 2; objects.append(TranslatedString(lang, str)); }