AIS: NMEA sentences must end with CR/LF. Don't read beyond end of array.

pull/1342/head
Jon Beniston 2022-07-17 13:15:17 +01:00
rodzic dcd0ee2272
commit 4ac05f427f
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -60,7 +60,11 @@ QString AISMessage::toNMEA(const QByteArray bytes)
int c = 0;
for (int j = 0; j < 6; j++)
{
c = (c << 1) | ((bytes[i] >> (bits - 1)) & 0x1);
if (i < bytes.size()) {
c = (c << 1) | ((bytes[i] >> (bits - 1)) & 0x1);
} else {
c = (c << 1);
}
bits--;
if (bits == 0)
{
@ -92,7 +96,7 @@ QString AISMessage::toNMEA(const QByteArray bytes)
sentence++;
}
return nmeaSentences.join("\n");
return nmeaSentences.join("\r\n").append("\r\n"); // NMEA-0183 requires CR and LF
}
QString AISMessage::toNMEA()