2004-06-04 Ken Raeburn <raeburn@mit.edu>
+ * str_conv.c (krb5_string_to_timestamp): Use localtime_r if
+ available.
+ (krb5_timestamp_to_string, krb5_timestamp_to_sfstring): Likewise.
+
* parse.c (krb5_parse_name): Use assert and abort, not exit.
* srv_rcache.c (krb5_get_server_rcache): Don't forget to actually
* indicated that no guarantees are made as to preserving timebuf
* when parsing fails
*/
+#ifdef HAVE_LOCALTIME_R
+ (void) localtime_r(&now, &timebuf);
+#else
memcpy(&timebuf, localtime(&now), sizeof(timebuf));
+#endif
if ((s = strptime(string, atime_format_table[i], &timebuf))
&& (s != string)) {
/* See if at end of buffer - otherwise partial processing */
{
int ret;
time_t timestamp2 = timestamp;
+ struct tm tmbuf;
const char *fmt = "%c"; /* This is to get around gcc -Wall warning that
the year returned might be two digits */
- ret = strftime(buffer, buflen, fmt, localtime(×tamp2));
+#ifdef HAVE_LOCALTIME_R
+ (void) localtime_r(×tamp2, &tmbuf);
+#else
+ memcpy(&tmbuf, localtime(×tamp2), sizeof(tmbuf));
+#endif
+ ret = strftime(buffer, buflen, fmt, &tmbuf);
if (ret == 0 || ret == buflen)
return(ENOMEM);
return(0);
size_t i;
size_t ndone;
time_t timestamp2 = timestamp;
+ struct tm tmbuf;
static const char * const sftime_format_table[] = {
"%c", /* Default locale-dependent date and time */
static const int sftime_format_table_nents =
sizeof(sftime_format_table)/sizeof(sftime_format_table[0]);
- tmp = localtime(×tamp2);
+#ifdef HAVE_LOCALTIME_R
+ tmp = localtime_r(×tamp2, &tmbuf);
+#else
+ memcpy((tmp = &tmbuf), localtime(×tamp2), sizeof(tmbuf));
+#endif
ndone = 0;
for (i=0; i<sftime_format_table_nents; i++) {
if ((ndone = strftime(buffer, buflen, sftime_format_table[i], tmp)))