+Thu Apr 16 17:01:27 1998 Tom Yu <tlyu@mit.edu>
+
+ * asn1_encode.c (asn1_encode_generaltime): Sanity check the return
+ from gmtime() to avoid overruns.
+
Fri Feb 27 18:03:33 1998 Theodore Ts'o <tytso@rsts-11.mit.edu>
* Makefile.in: Changed thisconfigdir to point at the lib/krb5
gmt_time = val + EPOCH;
gtime = gmtime(&gmt_time);
- /* Time encoding: YYYYMMDDhhmmssZ */
+ /*
+ * Time encoding: YYYYMMDDhhmmssZ
+ *
+ * Sanity check this just to be paranoid, as gmtime can return NULL,
+ * and some bogus implementations might overrun on the sprintf.
+ */
+ if (gtime == NULL ||
+ gtime->tm_year > 9999 || gtime->tm_mon > 11 ||
+ gtime->tm_mday > 31 || gtime->tm_hour > 23 ||
+ gtime->tm_min > 59 || gtime->tm_sec > 59)
+ return ASN1_BAD_GMTIME;
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);