diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-11-12 15:23:06 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-11-12 15:23:06 -0500 |
commit | c34effbe26313ad4519f2b66ac3531eb564277e3 (patch) | |
tree | c7855ba26427b446952f145e332a10ae811474f5 /drivers.c | |
parent | 08543646081a2c44423353067ddf58599d052a8c (diff) | |
download | gpsd-c34effbe26313ad4519f2b66ac3531eb564277e3.tar.gz |
Fix minor bugs in JSON packet passthrough.
Diffstat (limited to 'drivers.c')
-rw-r--r-- | drivers.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -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); |