diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2014-08-18 21:16:11 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2014-08-18 21:16:11 -0400 |
commit | 1bb19b7c55eb313577912bc6278ba92ee4dbbddb (patch) | |
tree | 1cab8c63009c850b8e3148630adc31722c51109b /gpsd_json.c | |
parent | f6bdf97aaf465036516a02ada69561441825d918 (diff) | |
download | gpsd-1bb19b7c55eb313577912bc6278ba92ee4dbbddb.tar.gz |
Prevent false match on Inland AIS messages.
Diffstat (limited to 'gpsd_json.c')
-rw-r--r-- | gpsd_json.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gpsd_json.c b/gpsd_json.c index 9a069a30..6d2ce51d 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -2810,12 +2810,21 @@ void json_aivdm_dump(const struct ais_t *ais, }; #define STATUS_DISPLAY(n) (((n) < (unsigned int)NITEMS(status_vocabulary)) ? status_vocabulary[n] : "INVALID STATUS") + structured = false; switch (ais->type8.fid) { case 10: /* Inland ship static and voyage-related data */ for (cp = shiptypes; cp < shiptypes + NITEMS(shiptypes); cp++) if (cp->code == ais->type8.dac200fid10.shiptype || cp->ais == ais->type8.dac200fid10.shiptype) break; + /* + * FIXME: AIS struct should have "structured" bit set by driver + * This is a kluge. + */ + if (cp->code == 0 + || ais->type8.dac200fid10.hazard >= NITEMS(hazard_types) + || !isascii(ais->type8.dac200fid10.vin[0])) + break; (void)snprintf(buf + strlen(buf), buflen - strlen(buf), "\"vin\":\"%s\",\"length\":%u,\"beam\":%u," "\"shiptype\":%u,\"shiptype_text\":\"%s\"," @@ -2841,6 +2850,12 @@ void json_aivdm_dump(const struct ais_t *ais, structured = true; break; case 23: /* EMMA warning */ + /* + * FIXME: AIS struct should have "structured" bit set by driver + * This is a kluge. + */ + if (ais->type8.dac200fid23.type >= NITEMS(emma_types)) + break; (void)snprintf(buf + strlen(buf), buflen - strlen(buf), "\"start\":\"%4u-%02u-%02uT%02u:%02u\"," "\"end\":\"%4u-%02u-%02uT%02u:%02u\",", |