+2004-06-04 Ken Raeburn <raeburn@mit.edu>
+
+ * asn1_encode.c (asn1_encode_generaltime): Use gmtime_r if
+ available.
+
2004-04-24 Ken Raeburn <raeburn@mit.edu>
* asn1_decode.c (asn1_decode_generaltime): If the input string is
unsigned int *retlen)
{
asn1_error_code retval;
- struct tm *gtime;
+ struct tm *gtime, gtimebuf;
char s[16], *sp;
unsigned int length, sum=0;
time_t gmt_time = val;
* Sanity check this just to be paranoid, as gmtime can return NULL,
* and some bogus implementations might overrun on the sprintf.
*/
+#ifdef HAVE_GMTIME_R
+ if (gmtime_r(&gmt_time, >imebuf) == NULL)
+ return ASN1_BAD_GMTIME;
+#else
gtime = gmtime(&gmt_time);
+ if (gtime == NULL)
+ return ASN1_BAD_GMTIME;
+ memcpy(gtimebuf, gtime, sizeof(gtimebuf));
+#endif
+ gtime = >imebuf;
- if (gtime == NULL ||
- gtime->tm_year > 8099 || gtime->tm_mon > 11 ||
+ if (gtime->tm_year > 8099 || gtime->tm_mon > 11 ||
gtime->tm_mday > 31 || gtime->tm_hour > 23 ||
gtime->tm_min > 59 || gtime->tm_sec > 59)
return ASN1_BAD_GMTIME;