gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gpsd-dev] Bug found in unix_to_iso8601()


From: Peter Liu
Subject: [gpsd-dev] Bug found in unix_to_iso8601()
Date: Thu, 08 Nov 2018 21:43:38 +0000 (GMT)

I found this bug but I will not be able to submit patches any time soon. I just don't have the energy to ask for approval from my upper management.

Could someone please take a quick look at the following in gpsutil.c? There should be a trivial fix.
    (void)snprintf(fractstr, sizeof(fractstr), "%.3f", fractional);

If the fractional part is 0.9995 or larger, it is rounded up and tractstr returns "1.000". It is not ".999".
The next line strips out the leading "1" from "1.000" and returns ".000"
    (void)snprintf(isotime, len, "%s%sZ",timestr, strchr(fractstr,'.'));

The end result is that with fixtime=1541766896.999512, unix_to_iso8601() produces "2018-11-09T12:34:56.000Z" instead of "2018-11-09T12:34:57.000Z". We lost one whole second.

Help is appreciated.

Peter Liu

reply via email to

[Prev in Thread] Current Thread [Next in Thread]