problem with nt-time <-> unix-time conversion un-specularity
simo.sorce at xsec.it
Wed Oct 8 22:40:35 GMT 2003
I lost 2 days catching a nice bug that ended to be caused by thye fact
that nt_time_to_unix() and unix_to_nt_time() are not specular.
When you convert times with unix_to_nt_time() you set NT_TIME to 0x7fff
ffff ffff ffff if unix time is TIME_T_MAX.
When you convert times with nt_time_to_unix() you set unix time to 0 in
the following cases:
nt time = 0 (that's ok :-)
nt time = 0xffff ffff ffff ffff (why ?)
nt time > TIME_T_MAX
nt time < TIME_T_MAX
this conversion break badly if you try to convert unix time -> nt time
-> unix time and unix time happen to be TIME_T_MAX.
Considering that nt time covers a bigger amount of time and to preserve
maximums conversions I think we should instead have nt_time_to_unix() to
behave this way:
nt time = 0 --> unix time = 0
nt time = 0xffff ffff ffff ffff --> unix time (-1 ? / TIME_T_MAX ?)
nt time >= TIME_T_MAX --> unix time = TIME_T_MAX
nt time =< TIME_T_MAX --> unix_time = TIME_T_MIN
here it is a patch just in case you agree complaetly with the prposed
change, if not, can you explain me where I'm in fault?
If it is a legacy problem, is it ok to create a new conversion function
that behave like I said?
Simo Sorce - simo.sorce at xsec.it
Xsec s.r.l. - http://www.xsec.it
via Durando 10 Ed. G - 20158 - Milano
mobile: +39 329 328 7702
tel. +39 02 2399 7130 - fax: +39 02 700 442 399
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 963 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20031009/e2b2a7d4/time.c.bin
More information about the samba-technical