1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

Fixed buffer overflow

This commit is contained in:
Martin Tůma 2020-01-05 00:50:02 +01:00
parent 6839119794
commit 8c9180190a

View File

@ -1,3 +1,4 @@
#include <cstring>
#include <QDataStream> #include <QDataStream>
#include <QTextCodec> #include <QTextCodec>
#include <QtEndian> #include <QtEndian>
@ -169,15 +170,16 @@ static quint32 readTranslatedObjects(QDataStream &stream, QTextCodec *codec,
QList<TranslatedString> &objects) QList<TranslatedString> &objects)
{ {
qint32 size = 0, ret; qint32 size = 0, ret;
char lang[2]; char lang[3];
memset(lang, 0, sizeof(lang));
objects.clear(); objects.clear();
stream >> size; stream >> size;
ret = size + 4; ret = size + 4;
while (stream.status() == QDataStream::Ok && size > 0) { while (stream.status() == QDataStream::Ok && size > 0) {
QString str; QString str;
stream.readRawData(lang, sizeof(lang)); stream.readRawData(lang, sizeof(lang) - 1);
size -= readString(stream, codec, str) + 2; size -= readString(stream, codec, str) + 2;
objects.append(TranslatedString(lang, str)); objects.append(TranslatedString(lang, str));
} }