NMEA0183 icon indicating copy to clipboard operation
NMEA0183 copied to clipboard

Parsing NMEA messages should be robust against to much fields

Open wellenvogel opened this issue 2 years ago • 5 comments

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.

wellenvogel avatar Mar 14 '22 09:03 wellenvogel

Thanks. Added it after increment.

ttlappalainen avatar Mar 22 '22 07:03 ttlappalainen

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

wellenvogel avatar Mar 22 '22 09:03 wellenvogel

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.

ttlappalainen avatar Mar 22 '22 09:03 ttlappalainen

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

wellenvogel avatar Mar 22 '22 09:03 wellenvogel

OK, now it is updated.

ttlappalainen avatar Mar 22 '22 09:03 ttlappalainen