From: Mark Eichin Date: Wed, 6 Jul 1994 17:38:49 +0000 (+0000) Subject: Get rid of strftime (since it breaks when used this way, at least under X-Git-Tag: krb5-1.0-beta4.2~157 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4857c8704af5696776c93d2b4052d08a1b84375e;p=krb5.git Get rid of strftime (since it breaks when used this way, at least under Solaris, and many systems don't even have it) in generaltime encoder. Use gmt_mktime in generaltime decoder. With these changes, kinit works again under Solaris 2. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3953 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/asn.1/ChangeLog b/src/lib/krb5/asn.1/ChangeLog index 21ff4de45..1f956d214 100644 --- a/src/lib/krb5/asn.1/ChangeLog +++ b/src/lib/krb5/asn.1/ChangeLog @@ -1,3 +1,14 @@ +Wed Jul 6 13:21:35 1994 Mark Eichin (eichin@cygnus.com) + + * asn1_encode.c (asn1_encode_generaltime): don't use strftime on + the output of gmtime -- under Solaris, it mutates it! (seems to be + doing a timezone offset.) Besides, sprintf is quite sufficient. + Also rename local variable time to gtime to avoid name collision. + (asn1_decode_generaltime): the fixed-point method below doesn't + actually work because it doesn't handle the current timezone + offset. Simpler, and more general -- always call gmt_mktime, which + is now provided in lib/krb5/os/gmt_mktime.c. + Sun Jul 3 04:43:42 1994 Tom Yu (tlyu at dragons-lair) * asn1_encode_k.h: diff --git a/src/lib/krb5/asn.1/asn1_decode.c b/src/lib/krb5/asn.1/asn1_decode.c index c9036538e..5aa584510 100644 --- a/src/lib/krb5/asn.1/asn1_decode.c +++ b/src/lib/krb5/asn.1/asn1_decode.c @@ -174,32 +174,9 @@ asn1_error_code asn1_decode_generaltime(DECLARG(asn1buf *, buf), ts.tm_min = 10*c2i(s[10]) + c2i(s[11]); ts.tm_sec = 10*c2i(s[12]) + c2i(s[13]); ts.tm_isdst = -1; - t = mktime(&ts); - if(t == -1) return ASN1_BAD_TIMEFORMAT; - -#define HAVE_GMTOFF -#ifdef HAVE_GMTOFF - t += ts.tm_gmtoff; /* Convert back to UTC timezone */ -#else - { - struct tm zg, zl; - time_t zero = 24*60*60; /* miss the year boundary */ - long delta; - - zl = *localtime(&zero); - zg = *gmtime(&zero); - - delta = (zl.tm_sec + 60*(zl.tm_min+60*(zl.tm_hour + 24*zl.tm_yday))) - - (zg.tm_sec + 60*(zg.tm_min+60*(zg.tm_hour + 24*zg.tm_yday))); + t = gmt_mktime(&ts); - if (ts.tm_isdst > 0) { - delta += 60*60; - } - -fprintf(stderr, "ASN1 DECODE: delta = %d\n", delta); - t += delta; - } -#endif + if(t == -1) return ASN1_BAD_TIMEFORMAT; *val = t; cleanup(); diff --git a/src/lib/krb5/asn.1/asn1_encode.c b/src/lib/krb5/asn.1/asn1_encode.c index 6b9920f5f..db8109ce0 100644 --- a/src/lib/krb5/asn.1/asn1_encode.c +++ b/src/lib/krb5/asn.1/asn1_encode.c @@ -185,12 +185,15 @@ asn1_error_code asn1_encode_generaltime(DECLARG(asn1buf *, buf), OLDDECLARG(int *, retlen) { asn1_error_code retval; - struct tm *time = gmtime(&val); + struct tm *gtime = gmtime(&val); char s[16]; int length, sum=0; /* Time encoding: YYYYMMDDhhmmssZ */ - if(!strftime(s,16,"%Y%m%d%H%M%SZ",time)) return ASN1_BAD_TIMEFORMAT; + sprintf(s, "%04d%02d%02d%02d%02d%02dZ", + 1900+gtime->tm_year, gtime->tm_mon+1, gtime->tm_mday, + gtime->tm_hour, gtime->tm_min, gtime->tm_sec); + retval = asn1buf_insert_charstring(buf,15,s); if(retval) return retval; sum = 15;