1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-03-14 02:57:45 +01:00

Limit maximal allowed CSV entries size

This commit is contained in:
Martin Tůma 2025-02-25 20:23:01 +01:00
parent 17ad10ba23
commit c5f51e935e
2 changed files with 6 additions and 3 deletions

View File

@ -7,15 +7,18 @@ RFC 4180 parser with the following enchancements:
- allows LF line ends in addition to CRLF line ends
*/
bool CSV::readEntry(QByteArrayList &list)
bool CSV::readEntry(QByteArrayList &list, int limit)
{
int state = 0;
int state = 0, len = 0;
char c;
QByteArray field;
list.clear();
while (_device->getChar(&c)) {
if (limit && ++len > limit)
return false;
switch (state) {
case 0:
if (c == '\r')

View File

@ -9,7 +9,7 @@ public:
CSV(QIODevice *device, char delimiter = ',')
: _device(device), _delimiter(delimiter), _line(1) {}
bool readEntry(QByteArrayList &list);
bool readEntry(QByteArrayList &list, int limit = 4096);
bool atEnd() const {return _device->atEnd();}
int line() const {return _line;}