1
0
Fork 0

Maintenance: nmea

overflow prevention
This commit is contained in:
Scott Giese 2021-02-21 16:02:50 -06:00
parent 08fce6d680
commit f56e2a1b3a

View file

@ -136,12 +136,12 @@ bool FGNMEA::gen_message()
double altitude_ft = mFdm.get_Altitude(); double altitude_ft = mFdm.get_Altitude();
char date[10]; char date[16];
{ {
int year = t->getGmt()->tm_year; unsigned short tm_mday = t->getGmt()->tm_mday;
while ( year >= 100 ) { year -= 100; } unsigned short tm_mon = t->getGmt()->tm_mon + 1;
snprintf( date, sizeof(date), "%02d%02d%02d", t->getGmt()->tm_mday, unsigned short tm_year = t->getGmt()->tm_year % 100;
t->getGmt()->tm_mon+1, year ); snprintf(date, sizeof(date), "%02u%02u%02u", tm_mday, tm_mon, tm_year);
} }
char magvar[10]; char magvar[10];