summaryrefslogtreecommitdiff
path: root/monitor_sirf.c
diff options
context:
space:
mode:
authorJon Schlueter <jon.schlueter@gmail.com>2010-05-29 22:33:24 -0400
committerJon Schlueter <jon.schlueter@gmail.com>2010-05-29 22:39:04 -0400
commit87a3f0f7ca5ef706f0a8977c034205d5b79dad77 (patch)
treec87d0bdbcca5fd64b2a784089dec3a5c788502be /monitor_sirf.c
parent7a3a6d97f58d5b95aa498f0c86932a7e3db1bf9e (diff)
downloadgpsd-87a3f0f7ca5ef706f0a8977c034205d5b79dad77.tar.gz
patch to keep gpsmon from crashing on unchecked data from sirf
gpsmon crashes in binary sirf mode if it receives a DGPS status message (1b) with negative first byte. Although this value is not documented by the sirf docs, my gps sends it. patch from Ladislav Sládeček
Diffstat (limited to 'monitor_sirf.c')
-rw-r--r--monitor_sirf.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/monitor_sirf.c b/monitor_sirf.c
index 7a0430fc..af03e2b8 100644
--- a/monitor_sirf.c
+++ b/monitor_sirf.c
@@ -59,6 +59,8 @@ static char *dgpsvec[] = {
"Software",
};
+#define CHECK_RANGE(vec, i) (((i) >= 0) && ((i) < sizeof(vec)/sizeof(vec[0])))
+
/*****************************************************************************
*
* SiRF packet-decoding routines
@@ -300,6 +302,7 @@ static void sirf_update(void)
int i, j, ch, off, cn;
unsigned char *buf;
size_t len;
+ uint8_t dgps;
assert(mid27win != NULL);
buf = session.packet.outbuffer + 4;
@@ -526,8 +529,9 @@ static void sirf_update(void)
total 3 x 12 = 36 bytes
******************************************************************/
+ dgps = getub(buf, 1);
display(mid27win, 1, 14, "%d (%s)",
- getub(buf, 1), dgpsvec[(int)getub(buf, 1)]);
+ dgps, (CHECK_RANGE(dgpsvec, dgps) ? dgpsvec[dgps] : "???"));
/*@ -type @*/
//(void) wmove(mid27win, 2, 0);
for (i = j = 0; i < 12; i++) {