ttlappalainen / NMEA0183

Library for handling NMEA0183 messages
69 stars 44 forks source link

Parsing NMEA messages should be robust against to much fields #35

Open wellenvogel opened 2 years ago

wellenvogel commented 2 years ago

Currently when you parse an NMEA0183 message (tNMEA0183Msg::SetMessage) there is no check against the field count. So if the message (accidently) contains more then 20 fields it will overwrite data leading to crashes. So there should be something like

if (_FieldCount >= MAX_NMEA0183_MSG_FIELDS){ Clear(); return false; } before line 101 of NMEA0183Message.cpp.

ttlappalainen commented 2 years ago

Thanks. Added it after increment.

wellenvogel commented 2 years ago

Maybe better before - otherwise you allow one field less...

ttlappalainen commented 2 years ago

You are rigth, but then it should be before line Fields[_FieldCount]=iData+1; // Set start of field On my code that is line 100.

wellenvogel commented 2 years ago

exactly... that's what I currently do.

ttlappalainen commented 2 years ago

OK, now it is updated.