summaryrefslogtreecommitdiff
path: root/drivers.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-11-12 15:23:06 -0500
committerEric S. Raymond <esr@thyrsus.com>2013-11-12 15:23:06 -0500
commitc34effbe26313ad4519f2b66ac3531eb564277e3 (patch)
treec7855ba26427b446952f145e332a10ae811474f5 /drivers.c
parent08543646081a2c44423353067ddf58599d052a8c (diff)
downloadgpsd-c34effbe26313ad4519f2b66ac3531eb564277e3.tar.gz
Fix minor bugs in JSON packet passthrough.
Diffstat (limited to 'drivers.c')
-rw-r--r--drivers.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers.c b/drivers.c
index f38d2569..1f0235e7 100644
--- a/drivers.c
+++ b/drivers.c
@@ -1436,19 +1436,21 @@ static gps_mask_t json_pass_packet(struct gps_device_t *session)
path_rewrite(session, "\"device\":\"");
/* mark certain responses without a path or device attribute */
- if (strstr((char *)session->packet.outbuffer, "VERSION") != NULL
- || strstr((char *)session->packet.outbuffer, "WATCH") != NULL
- || strstr((char *)session->packet.outbuffer, "DEVICES") != NULL) {
- session->packet.outbuffer[session->packet.outbuflen-1] = '\0';
- (void)strlcat((char *)session->packet.outbuffer, ",\"remote\":\"",
- sizeof(session->packet.outbuffer));
- (void)strlcat((char *)session->packet.outbuffer,
- session->gpsdata.dev.path,
- sizeof(session->packet.outbuffer));
- (void)strlcat((char *)session->packet.outbuffer, "\"}",
- sizeof(session->packet.outbuffer));
+ if (session->gpsdata.dev.path[0] != '\0') {
+ if (strstr((char *)session->packet.outbuffer, "VERSION") != NULL
+ || strstr((char *)session->packet.outbuffer, "WATCH") != NULL
+ || strstr((char *)session->packet.outbuffer, "DEVICES") != NULL) {
+ session->packet.outbuffer[session->packet.outbuflen-1] = '\0';
+ (void)strlcat((char *)session->packet.outbuffer, ",\"remote\":\"",
+ sizeof(session->packet.outbuffer));
+ (void)strlcat((char *)session->packet.outbuffer,
+ session->gpsdata.dev.path,
+ sizeof(session->packet.outbuffer));
+ (void)strlcat((char *)session->packet.outbuffer, "\"}",
+ sizeof(session->packet.outbuffer));
+ }
+ session->packet.outbuflen = (unsigned int)strlen((char *)session->packet.outbuffer);
}
-
gpsd_report(session->context->debug, LOG_PROG,
"JSON, passing through %s\n",
(char *)session->packet.outbuffer);