1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Limit line lengths in line-based parsers

This commit is contained in:
Martin Tůma 2022-07-05 11:08:57 +02:00
parent 99365c3ac8
commit 74b73d8700
9 changed files with 11 additions and 11 deletions

View File

@ -18,7 +18,7 @@ bool ITNParser::parse(QFile *file, QList<TrackData> &tracks,
_errorString.clear(); _errorString.clear();
while (!file->atEnd()) { while (!file->atEnd()) {
ba = file->readLine(); ba = file->readLine(4096);
QList<QByteArray> fields(ba.split('|')); QList<QByteArray> fields(ba.split('|'));
if (fields.size() < 4) { if (fields.size() < 4) {

View File

@ -45,7 +45,7 @@ bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
SegmentData &segment = track.last(); SegmentData &segment = track.last();
while (!file->atEnd()) { while (!file->atEnd()) {
QByteArray line = file->readLine(); QByteArray line = file->readLine(4096);
if (_errorLine == 1) { if (_errorLine == 1) {
QString fileType(QString::fromUtf8(line).trimmed()); QString fileType(QString::fromUtf8(line).trimmed());
@ -133,7 +133,7 @@ bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
while (!file->atEnd()) { while (!file->atEnd()) {
QByteArray line = file->readLine(); QByteArray line = file->readLine(4096);
if (_errorLine == 1) { if (_errorLine == 1) {
QString fileType(QString::fromUtf8(line).trimmed()); QString fileType(QString::fromUtf8(line).trimmed());
@ -233,7 +233,7 @@ bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
_errorString.clear(); _errorString.clear();
while (!file->atEnd()) { while (!file->atEnd()) {
QByteArray line = file->readLine(); QByteArray line = file->readLine(4096);
if (_errorLine == 1) { if (_errorLine == 1) {
QString fileType(QString::fromUtf8(line).trimmed()); QString fileType(QString::fromUtf8(line).trimmed());

View File

@ -90,7 +90,7 @@ bool TwoNavParser::parse(QFile *file, QList<TrackData> &tracks,
} }
while (!file->atEnd()) { while (!file->atEnd()) {
QByteArray line(file->readLine().trimmed()); QByteArray line(file->readLine(4096).trimmed());
if (!line.size()) if (!line.size())
continue; continue;

View File

@ -45,7 +45,7 @@ void Ellipsoid::loadList(const QString &path)
while (!file.atEnd()) { while (!file.atEnd()) {
ln++; ln++;
QByteArray line = file.readLine(); QByteArray line = file.readLine(4096);
QList<QByteArray> list = line.split(','); QList<QByteArray> list = line.split(',');
if (list.size() != 4) { if (list.size() != 4) {
qWarning("%s: %d: Format error", qPrintable(path), ln); qWarning("%s: %d: Format error", qPrintable(path), ln);

View File

@ -104,7 +104,7 @@ void GCS::loadList(const QString &path)
while (!file.atEnd()) { while (!file.atEnd()) {
ln++; ln++;
QByteArray line = file.readLine(); QByteArray line = file.readLine(4096);
QList<QByteArray> list = line.split(','); QList<QByteArray> list = line.split(',');
if (list.size() != 14) { if (list.size() != 14) {
qWarning("%s:%d: Format error", qPrintable(path), ln); qWarning("%s:%d: Format error", qPrintable(path), ln);

View File

@ -24,7 +24,7 @@ int MapFile::parse(QIODevice &device, QList<CalibrationPoint> &points,
while (!device.atEnd()) { while (!device.atEnd()) {
QByteArray line = device.readLine(); QByteArray line = device.readLine(4096);
if (ln == 1) { if (ln == 1) {
QString fileType(QString::fromUtf8(line).trimmed()); QString fileType(QString::fromUtf8(line).trimmed());

View File

@ -151,7 +151,7 @@ void PCS::loadList(const QString &path)
while (!file.atEnd()) { while (!file.atEnd()) {
ln++; ln++;
QByteArray line = file.readLine(); QByteArray line = file.readLine(4096);
QList<QByteArray> list = line.split(','); QList<QByteArray> list = line.split(',');
if (list.size() != 28) { if (list.size() != 28) {
qWarning("%s:%d: Format error", qPrintable(path), ln); qWarning("%s:%d: Format error", qPrintable(path), ln);

View File

@ -93,7 +93,7 @@ bool Tar::loadTmi(const QString &path)
return false; return false;
while (!file.atEnd()) { while (!file.atEnd()) {
QByteArray line = file.readLine(); QByteArray line = file.readLine(4096);
int pos = line.indexOf(':'); int pos = line.indexOf(':');
if (line.size() < 10 || pos < 7 || !line.startsWith("block")) { if (line.size() < 10 || pos < 7 || !line.startsWith("block")) {
qWarning("%s:%d: syntax error", qPrintable(path), ln); qWarning("%s:%d: syntax error", qPrintable(path), ln);

View File

@ -13,7 +13,7 @@ WLDFile::WLDFile(const QString &fileName)
} }
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
QByteArray line(file.readLine().trimmed()); QByteArray line(file.readLine(128).trimmed());
val[i] = line.toDouble(&ok); val[i] = line.toDouble(&ok);
if (!ok) { if (!ok) {
_errorString = line + ": invalid parameter"; _errorString = line + ": invalid parameter";