1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

GPS: fix buffer overrun in nmeaProcess()

nmeaProcess was attempting to null-terminate the
NMEA sentence but was not considering that the
preceeding loop may have looped beyond the end
of the packet buffer.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@709 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
stac 2010-06-03 13:58:18 +00:00 committed by stac
parent a03b948fb5
commit e2721136ae

View File

@ -233,7 +233,11 @@ uint8_t nmeaProcess(cBuffer* rxBuffer)
bufferGetFromFront(rxBuffer);
}
// null terminate it
NmeaPacket[j] = 0;
if (j<(NMEA_BUFFERSIZE-1)) {
NmeaPacket[j] = 0;
} else {
NmeaPacket[NMEA_BUFFERSIZE-1] = 0;
}
// dump <CR><LF> from rxBuffer
bufferGetFromFront(rxBuffer);
bufferGetFromFront(rxBuffer);