From 89bc05db05ec3f8f073852a46caa5b37ed87e2e1 Mon Sep 17 00:00:00 2001 From: Fred Wright Date: Fri, 16 Sep 2016 18:18:27 -0700 Subject: 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 --- drivers.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers.c') 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, -- cgit v1.2.1