From 74b73d8700c60a57e7196cee58f4c53140d05b94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Tue, 5 Jul 2022 11:08:57 +0200 Subject: [PATCH] Limit line lengths in line-based parsers --- src/data/itnparser.cpp | 2 +- src/data/oziparsers.cpp | 6 +++--- src/data/twonavparser.cpp | 2 +- src/map/ellipsoid.cpp | 2 +- src/map/gcs.cpp | 2 +- src/map/mapfile.cpp | 2 +- src/map/pcs.cpp | 2 +- src/map/tar.cpp | 2 +- src/map/wldfile.cpp | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/data/itnparser.cpp b/src/data/itnparser.cpp index 13ceb802..75519c11 100644 --- a/src/data/itnparser.cpp +++ b/src/data/itnparser.cpp @@ -18,7 +18,7 @@ bool ITNParser::parse(QFile *file, QList &tracks, _errorString.clear(); while (!file->atEnd()) { - ba = file->readLine(); + ba = file->readLine(4096); QList fields(ba.split('|')); if (fields.size() < 4) { diff --git a/src/data/oziparsers.cpp b/src/data/oziparsers.cpp index a56bd398..8f1e7ab1 100644 --- a/src/data/oziparsers.cpp +++ b/src/data/oziparsers.cpp @@ -45,7 +45,7 @@ bool PLTParser::parse(QFile *file, QList &tracks, SegmentData &segment = track.last(); while (!file->atEnd()) { - QByteArray line = file->readLine(); + QByteArray line = file->readLine(4096); if (_errorLine == 1) { QString fileType(QString::fromUtf8(line).trimmed()); @@ -133,7 +133,7 @@ bool RTEParser::parse(QFile *file, QList &tracks, while (!file->atEnd()) { - QByteArray line = file->readLine(); + QByteArray line = file->readLine(4096); if (_errorLine == 1) { QString fileType(QString::fromUtf8(line).trimmed()); @@ -233,7 +233,7 @@ bool WPTParser::parse(QFile *file, QList &tracks, _errorString.clear(); while (!file->atEnd()) { - QByteArray line = file->readLine(); + QByteArray line = file->readLine(4096); if (_errorLine == 1) { QString fileType(QString::fromUtf8(line).trimmed()); diff --git a/src/data/twonavparser.cpp b/src/data/twonavparser.cpp index d1914a70..76c91c0d 100644 --- a/src/data/twonavparser.cpp +++ b/src/data/twonavparser.cpp @@ -90,7 +90,7 @@ bool TwoNavParser::parse(QFile *file, QList &tracks, } while (!file->atEnd()) { - QByteArray line(file->readLine().trimmed()); + QByteArray line(file->readLine(4096).trimmed()); if (!line.size()) continue; diff --git a/src/map/ellipsoid.cpp b/src/map/ellipsoid.cpp index 28b51310..8b71b96a 100644 --- a/src/map/ellipsoid.cpp +++ b/src/map/ellipsoid.cpp @@ -45,7 +45,7 @@ void Ellipsoid::loadList(const QString &path) while (!file.atEnd()) { ln++; - QByteArray line = file.readLine(); + QByteArray line = file.readLine(4096); QList list = line.split(','); if (list.size() != 4) { qWarning("%s: %d: Format error", qPrintable(path), ln); diff --git a/src/map/gcs.cpp b/src/map/gcs.cpp index 3b0bcd89..ed2abf30 100644 --- a/src/map/gcs.cpp +++ b/src/map/gcs.cpp @@ -104,7 +104,7 @@ void GCS::loadList(const QString &path) while (!file.atEnd()) { ln++; - QByteArray line = file.readLine(); + QByteArray line = file.readLine(4096); QList list = line.split(','); if (list.size() != 14) { qWarning("%s:%d: Format error", qPrintable(path), ln); diff --git a/src/map/mapfile.cpp b/src/map/mapfile.cpp index 129f9d15..fc21f1ce 100644 --- a/src/map/mapfile.cpp +++ b/src/map/mapfile.cpp @@ -24,7 +24,7 @@ int MapFile::parse(QIODevice &device, QList &points, while (!device.atEnd()) { - QByteArray line = device.readLine(); + QByteArray line = device.readLine(4096); if (ln == 1) { QString fileType(QString::fromUtf8(line).trimmed()); diff --git a/src/map/pcs.cpp b/src/map/pcs.cpp index 7910bed7..e8ff8bf8 100644 --- a/src/map/pcs.cpp +++ b/src/map/pcs.cpp @@ -151,7 +151,7 @@ void PCS::loadList(const QString &path) while (!file.atEnd()) { ln++; - QByteArray line = file.readLine(); + QByteArray line = file.readLine(4096); QList list = line.split(','); if (list.size() != 28) { qWarning("%s:%d: Format error", qPrintable(path), ln); diff --git a/src/map/tar.cpp b/src/map/tar.cpp index c56366f7..0ed8e1d9 100644 --- a/src/map/tar.cpp +++ b/src/map/tar.cpp @@ -93,7 +93,7 @@ bool Tar::loadTmi(const QString &path) return false; while (!file.atEnd()) { - QByteArray line = file.readLine(); + QByteArray line = file.readLine(4096); int pos = line.indexOf(':'); if (line.size() < 10 || pos < 7 || !line.startsWith("block")) { qWarning("%s:%d: syntax error", qPrintable(path), ln); diff --git a/src/map/wldfile.cpp b/src/map/wldfile.cpp index 56752402..04dfd978 100644 --- a/src/map/wldfile.cpp +++ b/src/map/wldfile.cpp @@ -13,7 +13,7 @@ WLDFile::WLDFile(const QString &fileName) } for (int i = 0; i < 6; i++) { - QByteArray line(file.readLine().trimmed()); + QByteArray line(file.readLine(128).trimmed()); val[i] = line.toDouble(&ok); if (!ok) { _errorString = line + ": invalid parameter";