[PATCH 0/2] Fix divinglog import

Linus Torvalds torvalds at linux-foundation.org
Sat Oct 7 13:47:44 PDT 2017


Two patches: the first one is the important one.

That one fixes the absolutely horrid import parsing, which was broken in 
multiple ways. Not only didn't it check the string sizes for the source 
data correctly, even when the source data existed properly it would copy 
the numbers with a "memcpy()" and then do "atoi()" on the result. Which 
sounds fine, but nothing actually cleared the temporary buffer at any 
point, so the copy didn't necessarily have a terminating NULL character at 
all.

It would generally work, simply because you don't even need a terminating 
NUL character, you just need the final character to not be ASCII '0'-'9'. 
So almost always it worked in practice. Except when it didn't, and it 
happened to get odd results.

That first patch fixes things, and the test case is valgrind-clean 
afterwards. 

The second patch is unrelated to the limit checking - while fixing the 
code I noticed that the temperature values were truncated by doing an 
integer divide by 10, which caused all the sample temperatures to be 
reported as whole degrees C (rounded towards zero). 

That's just a one-liner code change to do it as a proper FP divide, but 
then the test results obviously change a lot, so the bulk of the patch is 
to update the result file to have the full temperature information.


Linus Torvalds (2):
  Fix divinglog import limit checking
  Fix divinglog import temperature truncation

 core/parse-xml.c    | 189 ++++++++++++++++++++++++++++------------------------
 dives/test40-42.xml | 126 +++++++++++++++++------------------
 2 files changed, 166 insertions(+), 149 deletions(-)

-- 
2.14.2.608.geb47b4193.dirty



More information about the subsurface mailing list