From 5ee8b5f73f0b0b01321b853d0c27902452a21397 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 24 Aug 2014 11:49:53 -0400 Subject: Add a minor error check to AIVDM parsing. --- drivers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers.c') diff --git a/drivers.c b/drivers.c index 1e809e5e..eb8a41ee 100644 --- a/drivers.c +++ b/drivers.c @@ -1218,7 +1218,6 @@ static bool aivdm_decode(const char *buf, size_t buflen, } switch (field[4][0]) { - /* FIXME: if fields[4] == "12", it doesn't detect the error */ case '\0': /* * Apparently an empty channel is normal for AIVDO sentences, @@ -1232,6 +1231,11 @@ static bool aivdm_decode(const char *buf, size_t buflen, session->driver.aivdm.ais_channel ='A'; break; case '1': + if (strcmp((char *)field[4], (char *)"12") == 0) { + gpsd_report(session->context->debug, LOG_INF, + "ignoring bogus AIS channel '12'.\n"); + return false; + } /*@fallthrough@*/ case 'A': ais_context = &session->driver.aivdm.context[0]; -- cgit v1.2.1