Don't accept all-zeros messages (e.g. off the network - the demodulator

doesn't accept them already)
This commit is contained in:
Oliver Jowett 2016-09-14 16:11:31 +01:00
parent b827806ce8
commit 9e179d46bf

View file

@ -307,12 +307,12 @@ static inline __attribute__((always_inline)) unsigned getbits(unsigned char *da
// -1: message might be valid, but we couldn't validate the CRC against a known ICAO
// -2: bad message or unrepairable CRC error
static unsigned char all_zeros[14] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
int scoreModesMessage(unsigned char *msg, int validbits)
{
int msgtype, msgbits, crc, iid;
uint32_t addr;
struct errorinfo *ei;
static unsigned char all_zeros[14] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
if (validbits < 56)
return -2;
@ -434,6 +434,10 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
}
msg = mm->msg;
// don't accept all-zeros messages
if (!memcmp(all_zeros, msg, 7))
return -2;
// Get the message type ASAP as other operations depend on this
mm->msgtype = getbits(msg, 1, 5); // Downlink Format
mm->msgbits = modesMessageLenByType(mm->msgtype);