summaryrefslogtreecommitdiff
path: root/driver_aivdm.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-01-28 01:35:44 +0000
committerEric S. Raymond <esr@thyrsus.com>2010-01-28 01:35:44 +0000
commit0617aa7b5166549c2d18457b1c54e3e281d5f7cf (patch)
tree5dea5f8dc90ba3eda8e7b77537985c47b144b61b /driver_aivdm.c
parentd12b49d94143f05c8754ac9db2e0b4364ba363ac (diff)
downloadgpsd-0617aa7b5166549c2d18457b1c54e3e281d5f7cf.tar.gz
More message-length chexks for AIS.
Diffstat (limited to 'driver_aivdm.c')
-rw-r--r--driver_aivdm.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/driver_aivdm.c b/driver_aivdm.c
index 959589c4..c0afc808 100644
--- a/driver_aivdm.c
+++ b/driver_aivdm.c
@@ -155,6 +155,12 @@ bool aivdm_decode(const char *buf, size_t buflen,
case 1: /* Position Report */
case 2:
case 3:
+ if (ais_context->bitlen != 168) {
+ gpsd_report(LOG_ERROR, "AIVDM message type %d size not 168 bits (%zd).\n",
+ ais->type,
+ ais_context->bitlen);
+ break;
+ }
ais->type1.status = UBITS(38, 4);
ais->type1.turn = SBITS(42, 8);
ais->type1.speed = UBITS(50, 10);
@@ -182,6 +188,11 @@ bool aivdm_decode(const char *buf, size_t buflen,
break;
case 4: /* Base Station Report */
case 11: /* UTC/Date Response */
+ if (ais_context->bitlen != 168) {
+ gpsd_report(LOG_ERROR, "AIVDM message type 4 size not 168 bits (%zd).\n",
+ ais_context->bitlen);
+ break;
+ }
ais->type4.year = UBITS(38, 14);
ais->type4.month = UBITS(52, 4);
ais->type4.day = UBITS(56, 5);