diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2018-12-26 11:31:19 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2018-12-26 11:31:19 -0500 |
commit | a9f6fa7274855c3bacc13873264bd59e6f3169e3 (patch) | |
tree | b03760d9e67c08ec284676026024e103f0af3a91 /serial.c | |
parent | 5144e1c3c1408cb5edf987e26073eab55ef24507 (diff) | |
download | gpsd-a9f6fa7274855c3bacc13873264bd59e6f3169e3.tar.gz |
Address Savannah bug #53621: Invalid JSON generated for an unreadable device
Diffstat (limited to 'serial.c')
-rw-r--r-- | serial.c | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -292,6 +292,19 @@ void gpsd_set_speed(struct gps_device_t *session, else rate = B230400; + /* backward-compatibility hack */ + switch (parity) { + case (char)2: + parity = 'E'; + break; + case (char)1: + parity = 'O'; + break; + case (char)0: + parity = 'N'; /* without this we might emit malformed JSON */ + break; + } + if (rate != cfgetispeed(&session->ttyset) || parity != session->gpsdata.dev.parity || stopbits != session->gpsdata.dev.stopbits) { @@ -315,12 +328,10 @@ void gpsd_set_speed(struct gps_device_t *session, session->ttyset.c_cflag |= (stopbits == 2 ? CS7 | CSTOPB : CS8); switch (parity) { case 'E': - case (char)2: session->ttyset.c_iflag |= INPCK; session->ttyset.c_cflag |= PARENB; break; case 'O': - case (char)1: session->ttyset.c_iflag |= INPCK; session->ttyset.c_cflag |= PARENB | PARODD; break; |