Get rid of strftime (since it breaks when used this way, at least under
authorMark Eichin <eichin@mit.edu>
Wed, 6 Jul 1994 17:38:49 +0000 (17:38 +0000)
committerMark Eichin <eichin@mit.edu>
Wed, 6 Jul 1994 17:38:49 +0000 (17:38 +0000)
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

src/lib/krb5/asn.1/ChangeLog
src/lib/krb5/asn.1/asn1_decode.c
src/lib/krb5/asn.1/asn1_encode.c

index 21ff4de4541d57cd5a343aa6f88437f45040009c..1f956d2148f89069e03baaacff49f790254c39cc 100644 (file)
@@ -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:
index c9036538e6ddb20dd45d56f7513ee05e4485a959..5aa5845103b0ca759af0460e2278e8dfc00d78d2 100644 (file)
@@ -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();
index 6b9920f5f3efb8d13909a16fe909fa996c06d52d..db8109ce080c5ddbe3fc34103f0167694184b5d8 100644 (file)
@@ -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;