summaryrefslogtreecommitdiff
path: root/shmexport.c
diff options
context:
space:
mode:
authorStefan Roels <sroels-gpsd-dev@42solutions.nl>2015-10-02 22:11:12 -0400
committerJon Schlueter <jschlueter@redhat.com>2015-10-03 08:03:45 -0400
commitfd0055547841966d2b7815cc8ca515879a0ac1ae (patch)
tree2f4a6d79a82ef9e5656288eb24c32c9adf083b2c /shmexport.c
parent5b926e8abda5371eb2ea9e8b4aca5470e5358f73 (diff)
downloadgpsd-fd0055547841966d2b7815cc8ca515879a0ac1ae.tar.gz
Fixup driver_ais from_sixbit parsing
One of these problems has to do with the removal of spaces at the end of the six bits ascii strings. According to the documentation, the following steps should be taken: - Remove everything from the first @ sign (including the @ sign itself) - Strip trailing spaces from the result The existing code however fails to do so properly in certain circumstances. Consider the following scenarios (all assuming count = 20, e.g. type 5 field shipname): 1) The input string: "ALPHA @@@@@@@@@@@@@@" (single space before first @ character) The from_sixbit function will take i from 0 up to and including 6, where it will see the @ and break. to[6] will then be set to \0. Now the second part of the algorithm kicks in and starts at i=18. I could not find where the field was initialised, so I am not sure whether the field would be zero-filled, @ or space filled or random junk, but in any case either we find spaces or @ signs until we reach i=6, or we break at i>6. This would leave us with: "ALPHA \0..." The space at to[5] will not be cleared. 2) The input string: "ALPHA BRAVO CHARLIE " (single space at the end) The from_sixbit function will take i from 0 up to and including 20, the break condition of the for loop will be met and we set to[20] to \0. At that moment we get to the second part of the algorithm which would look at to[18] which is 'E' and break without removing the trailing space. 3) The input string: "ALPHA BRAVO CHARLI E" (space as character before the last one) The from_sixbit function will take i from 0 up to and including 20, the break condition of the for loop will be met and we set to[20] to \0. At that moment we get to the second part of the algorithm which would look at to[18] which is ' ' and will replace it with a \0, dropping the E at the end. Another spacing problem lies within the type 21 name/name extension field. If the name field would be trimmed, but there is data in the name extension field, the name extension would not be taken into account. Take for instance the following examples: name:"ALPHA BRAVO CHARLI E" name extension:"CHO" (assuming the incorrect space removal) result: "ALPHA BRAVO CHARLI" instead of "ALPHA BRAVO CHARLI ECHO" name:"ALPHA BRAVO CHARLIE " name extension:"DELTA" (assuming removal of the trailing space of name) result "ALPHA BRAVO CHARLIE" instead of "ALPHA BRAVO CHARLIE DELTA" I have created a patch to solve the problems mentioned above. You can find the patch and some examples of real world messages going wrong below. Best regards, Stefan Roels Added sample data from email and applied provided patch Signed-off-by: Jon Schlueter <jschlueter@redhat.com>
Diffstat (limited to 'shmexport.c')
0 files changed, 0 insertions, 0 deletions