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

Re: Problems with kadmin date parsing in heimdal 0.6.1 on NetBSD



Mark Davies <mark@MCS.VUW.AC.NZ> writes:

> On examining the date parsing routines in kadmin/util.c, the routine
>  str2time_t contains two calls to strptime().  The first parses "%Y-%m-%d"
>  which works fine.  The 2nd attempts to parse "%H:%M:%S" but fails because
>  the first character in the string it is passed is a " ".  If the format is
>  changed to be " %H:%M:%S" the right thing happens.
>
> This problem doesn't occur on a Solaris 8 system, so it could be argued that
> the problem lies with NetBSD's strptime() routine.  I'm not sure about the
> other BSD's or other systems. [My reading of posix.1-2003 strptime() indicates 
> that the " " or a %n or %t is required to eat the leading space - mark]

This has been fixed in CVS.

> Also looking at the code in that routine, it is attempting to
> default to the end of the day if a time is not specified.  But that
> doesn't work because the assignment of the default is done to the
> tm2 structure rather than tm.

Obviously a bug, fixed now. Thanks.

> (a) str2time_t should call tm2time() with 1 as the last parameter, which
>  would mean that the date specified to kadmin would be interpreted as being
>  in your local time zone and take into account daylight savings when
>  converting it to a time_t; or

No, this isn't right. Times should be in UTC.

> (b) tm2time() should set tm.tm_isdst to 0 which I think would make mktime()
> ignore daylight savings time.

More like it, but how about this:

--- tm2time.c	1999/12/02 16:58:53	1.7
+++ tm2time.c	2004/05/07 09:09:33
@@ -51,7 +51,7 @@
 {
      time_t t;
 
-    tm.tm_isdst = -1;
+    tm.tm_isdst = local ? -1 : 0;
 
      t = mktime (&tm);
 
/Johan