summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Wright <fw@fwright.net>2016-09-16 18:18:27 -0700
committerGary E. Miller <gem@rellim.com>2016-09-22 16:56:26 -0700
commit89bc05db05ec3f8f073852a46caa5b37ed87e2e1 (patch)
treea77a8f5d65b1a4c5f1999ac1905cf73003bbabef
parent21eb174671474947688c5afee8e92a637b2fb149 (diff)
downloadgpsd-89bc05db05ec3f8f073852a46caa5b37ed87e2e1.tar.gz
Fixes Ill-formed TOFF/PPS packet error in gpsmon.
The code for reporting the combined host address and device address modifies the same 'path' field that it uses to form the combination This was resulting in a growing accumulation of device names until the string became too long. Although the way this code works could use some improvement, a cheap fix is to check for the presence of the device name in the path, and skip it when creating the new one. TESTED: On both OSX and Linux, ran "scons build-all check" and tested gpsmon both with and without the -a option, verifying that it no longer fails and that the reported "device" is the expected combined form. Signed-off-by: Gary E. Miller <gem@rellim.com>
-rw-r--r--drivers.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers.c b/drivers.c
index 98a24854..ebbcc6d6 100644
--- a/drivers.c
+++ b/drivers.c
@@ -1608,7 +1608,7 @@ static void path_rewrite(struct gps_device_t *session, char *prefix)
* beginning of the path attribute, followed by a # to separate it
* from the device.
*/
- char *prefloc;
+ char *prefloc, *sfxloc;
assert(prefix != NULL && session->lexer.outbuffer != NULL);
@@ -1628,6 +1628,8 @@ static void path_rewrite(struct gps_device_t *session, char *prefix)
(void)strlcpy(prefloc,
session->gpsdata.dev.path,
sizeof(session->gpsdata.dev.path));
+ if ((sfxloc = strchr(prefloc, '#')))
+ *sfxloc = '\0'; /* Avoid accumulating multiple device names */
(void)strlcat((char *)session->lexer.outbuffer, "#",
sizeof(session->lexer.outbuffer));
(void)strlcat((char *)session->lexer.outbuffer,