summaryrefslogtreecommitdiff
path: root/driver_proto.c
diff options
context:
space:
mode:
authorChris Kuethe <ckuethe@users.berlios.de>2010-05-10 11:35:32 -0500
committerChris Kuethe <ckuethe@users.berlios.de>2010-05-10 11:35:32 -0500
commit1e69fad41fd81522267214f54080850157697e75 (patch)
tree99f453bbaef662cf80977bd74e49a83c08d3bc9b /driver_proto.c
parentbce9340a35c2bb26e56be609b8ec22ec0752a309 (diff)
downloadgpsd-1e69fad41fd81522267214f54080850157697e75.tar.gz
a bit of armor for variable length packet decodes
after discussion with sanooj
Diffstat (limited to 'driver_proto.c')
-rw-r--r--driver_proto.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/driver_proto.c b/driver_proto.c
index 367158ab..1189e891 100644
--- a/driver_proto.c
+++ b/driver_proto.c
@@ -162,8 +162,8 @@ _proto__msg_utctime(struct gps_device_t *session, unsigned char *buf, size_t dat
session->context->leap_seconds = GET_GPS_LEAPSECONDS();
session->context->gps_tow = tow / 1000.0;
- t = gpstime_to_unix(gps_week, session->context->gps_tow)
- - session->context->leap_seconds;
+ t = gpstime_to_unix(gps_week, session->context->gps_tow)
+ - session->context->leap_seconds;
session->newdata.time = t;
return TIME_IS | ONLINE_IS;
@@ -195,6 +195,10 @@ _proto__msg_svinfo(struct gps_device_t *session, unsigned char *buf, size_t data
* be set to the number of satellites which might be visible.
*/
nchan = GET_NUMBER_OF_CHANNELS();
+ if ((nchan < 1) || (nchan > MAXCHANNELS)) {
+ gpsd_report(LOG_INF, "too many channels reported\n");
+ return 0;
+ }
gpsd_zero_satellites(&session->gpsdata);
nsv = 0; /* number of actually used satellites */
for (i = st = 0; i < nchan; i++) {
@@ -216,9 +220,9 @@ _proto__msg_svinfo(struct gps_device_t *session, unsigned char *buf, size_t data
session->gpsdata.skyview_time = NaN;
session->gpsdata.satellites_used = nsv;
session->gpsdata.satellites_visible = st;
- gpsd_report(LOG_DATA,
+ gpsd_report(LOG_DATA,
"SVINFO: visible=%d used=%d mask={SATELLITE|USED}\n",
- session->gpsdata.satellites_visible,
+ session->gpsdata.satellites_visible,
session->gpsdata.satellites_used);
return SATELLITE_IS | USED_IS;
}