2.2.2 Bug in unix_to_nt_time() + Fix
Jordan Russell
jr-list-samba-technical at quo.to
Sat Feb 2 02:04:03 GMT 2002
Today I came across a significant bug in time.c's unix_to_nt_time() function
that causes file time stamps to be 1 hour off when a file was last modified
within hours of Daylight Savings Time going into effect.
Let me give an example of the problem by showing two 'dir' listings (in
M-D-Y format). First, from a FAT32 partition on a Windows 2000 machine:
01/18/99 13:20 566 file1.txt
04/02/99 22:10 1,029 file2.txt
04/03/99 22:19 445 file3.txt
04/04/99 10:00 0 file4.txt
Now here are the very same files copied to a Samba share:
01/18/99 13:20 566 file1.txt
04/02/99 22:10 1,029 file2.txt
04/03/99 23:19 445 file3.txt
04/04/99 10:00 0 file4.txt
The dates/times are the same between the two listings, *except* in the case
of file3.txt. It's one hour ahead on the Samba share. This is wrong because
DST didn't go into effect until 04/04/99 @ 02:00 where I live (U.S.).
It seems the bug is that unix_to_nt_time() is passing a GMT time to
LocTimeDiff() instead of a local time. Here is the simple fix:
--- time.c.ORIG Sat Oct 13 16:09:25 2001
+++ time.c Sat Feb 2 02:56:48 2002
@@ -335,7 +335,7 @@
}
/* this converts GMT to kludge-GMT */
- t -= LocTimeDiff(t) - serverzone;
+ t -= LocTimeDiff(t - serverzone) - serverzone;
d = (double)(t);
d += TIME_FIXUP_CONSTANT;
Maybe this can be squeezed into 2.2.3? :)
Jordan Russell
More information about the samba-technical
mailing list