summaryrefslogtreecommitdiff
path: root/src/nmea-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nmea-parser.c')
-rw-r--r--src/nmea-parser.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/nmea-parser.c b/src/nmea-parser.c
index 3e8b003..195a220 100644
--- a/src/nmea-parser.c
+++ b/src/nmea-parser.c
@@ -7,6 +7,21 @@
*
* Author: Iain Holmes <iain@gnome.org>
* Copyright (C) 2007
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
*/
/*
@@ -284,6 +299,9 @@ parse_gsv (NMEAParseContext *ctxt,
}
#endif
+ if (field_count < GSV_FIELDS)
+ return FALSE;
+
message_number = atoi (GSV_FIELD (1));
if (message_number != ctxt->message_count + 1) {
@@ -378,6 +396,9 @@ parse_gsa (NMEAParseContext *ctxt,
}
#endif
+ if (field_count < GSA_FIELDS)
+ return FALSE;
+
/* We actually have a real fix type now */
gypsy_client_set_fix_type (ctxt->client, atoi (GSA_FIELD(1)), FALSE);
@@ -397,7 +418,7 @@ parse_gsa (NMEAParseContext *ctxt,
gypsy_client_set_accuracy
(ctxt->client,
*GSA_FIELD(14) ? ACCURACY_POSITION : 0 |
- *GSA_FIELD(15) ? ACCURACY_HORIZONAL : 0 |
+ *GSA_FIELD(15) ? ACCURACY_HORIZONTAL : 0 |
*GSA_FIELD(16) ? ACCURACY_VERTICAL : 0,
g_strtod (GSA_FIELD(14), NULL),
g_strtod (GSA_FIELD(15), NULL),
@@ -448,6 +469,9 @@ parse_gga (NMEAParseContext *ctxt,
}
#endif
+ if (field_count < GGA_FIELDS)
+ return FALSE;
+
timestamp = calculate_timestamp (ctxt, GGA_FIELD(0));
if (timestamp > 0) {
gypsy_client_set_timestamp (ctxt->client, timestamp);
@@ -474,7 +498,7 @@ parse_gga (NMEAParseContext *ctxt,
}
gypsy_client_set_fix_type (ctxt->client, fix_type, FALSE);
- gypsy_client_set_accuracy (ctxt->client, ACCURACY_HORIZONAL,
+ gypsy_client_set_accuracy (ctxt->client, ACCURACY_HORIZONTAL,
0, g_strtod (GGA_FIELD(7), NULL), 0);
return TRUE;
@@ -520,6 +544,9 @@ parse_rmc (NMEAParseContext *ctxt,
}
#endif
+ if (field_count < RMC_FIELDS)
+ return FALSE;
+
/* We can store the datestamp now */
ctxt->datestamp = calculate_datestamp (ctxt, RMC_FIELD(8));