Sanity Check on msglen after decoding

Add a sanity check to ensure that msglen is consistent with the DF type.
This commit is contained in:
Malcolm Robb 2013-04-30 10:32:23 +01:00
parent 5f7ed42050
commit 8d65abd317

View file

@ -56,7 +56,7 @@
// MinorVer changes when additional features are added, but not for bug fixes (range 00-99)
// DayDate & Year changes for all changes, including for bug fixes. It represent the release date of the update
//
#define MODES_DUMP1090_VERSION "1.04.2904.13"
#define MODES_DUMP1090_VERSION "1.04.3004.13"
#define MODES_DEFAULT_RATE 2000000
#define MODES_DEFAULT_FREQ 1090000000
@ -1972,9 +1972,12 @@ void detectModeS(uint16_t *m, uint32_t mlen) {
}
}
if (msglen == modesMessageLenByType(theByte = msg[0])) {
// The msglen is consistent with the DF type
if ((errorsTy == 1) && (theErrs & 0x78)) {
// Ensure msglen is consistent with the DF type
i = modesMessageLenByType(msg[0] >> 3);
if (msglen > i) {msglen = i;}
else if (msglen < i) {msglen = 0;}
if ((msglen) && (errorsTy == 1) && (theErrs & 0x78)) {
// We guessed at one of the message type bits. See if our guess is "likely"
// to be correct by comparing the DF against a list of known good DF's
int DF = ((theByte = msg[0]) >> 3) & 0x1f;
@ -1993,7 +1996,6 @@ void detectModeS(uint16_t *m, uint32_t mlen) {
}
}
}
}
// We measured signal strength over the first 56 bits. Don't forget to add 4
// for the preamble samples, so round up and divide by 60.