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
+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:
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();
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;