Don't accept all-zeros messages (e.g. off the network - the demodulator
doesn't accept them already)
This commit is contained in:
parent
b827806ce8
commit
9e179d46bf
6
mode_s.c
6
mode_s.c
|
@ -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
|
// -1: message might be valid, but we couldn't validate the CRC against a known ICAO
|
||||||
// -2: bad message or unrepairable CRC error
|
// -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 scoreModesMessage(unsigned char *msg, int validbits)
|
||||||
{
|
{
|
||||||
int msgtype, msgbits, crc, iid;
|
int msgtype, msgbits, crc, iid;
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
struct errorinfo *ei;
|
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)
|
if (validbits < 56)
|
||||||
return -2;
|
return -2;
|
||||||
|
@ -434,6 +434,10 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
|
||||||
}
|
}
|
||||||
msg = mm->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
|
// Get the message type ASAP as other operations depend on this
|
||||||
mm->msgtype = getbits(msg, 1, 5); // Downlink Format
|
mm->msgtype = getbits(msg, 1, 5); // Downlink Format
|
||||||
mm->msgbits = modesMessageLenByType(mm->msgtype);
|
mm->msgbits = modesMessageLenByType(mm->msgtype);
|
||||||
|
|
Loading…
Reference in a new issue