* This will break if bytes are more than 8 bits.
*/
#define MAX_CHARS_FOR_INT_TYPE(TYPE) ((int) (2 + 2.408241 * sizeof (TYPE)))
- char tmpbuf[MAX_CHARS_FOR_INT_TYPE(int) * 4 + 8];
days = (int) (deltat / (24*3600L));
dt = deltat % (24*3600L);
minutes = (int) (dt / 60);
seconds = (int) (dt % 60);
- memset (tmpbuf, 0, sizeof (tmpbuf));
if (days == 0)
snprintf(buffer, buflen, "%d:%02d:%02d", hours, minutes, seconds);
else if (hours || minutes || seconds)
else
snprintf(buffer, buflen, "%d %s", days,
(days > 1) ? "days" : "day");
- if (tmpbuf[sizeof(tmpbuf)-1] != 0)
- /* Something must be very wrong with my math above, or the
- assumptions going into it... */
- abort ();
- if (strlen (tmpbuf) > buflen)
- return ENOMEM;
- else
- strncpy (buffer, tmpbuf, buflen);
return 0;
}
}
}
+/* ctime() for uint32_t* */
+static char *
+ctime_uint32(uint32_t *time32)
+{
+ time_t tmp;
+ tmp = *time32;
+ return ctime(&tmp);
+}
+
/*
* Display time information.
*/
static void
-print_time(unsigned int *timep)
+print_time(uint32_t *timep)
{
if (*timep == 0L)
printf("\t\t\tNone\n");
else {
- time_t ltime = *timep;
- printf("\t\t\t%s", ctime(<ime));
+ printf("\t\t\t%s", ctime_uint32(timep));
}
}
+static void
+print_deltat(uint32_t *deltat)
+{
+ krb5_error_code ret;
+ static char buf[30];
+ ret = krb5_deltat_to_string(*deltat, buf, sizeof(buf));
+ if (ret)
+ printf("\t\t\t(error)\n");
+ else
+ printf("\t\t\t%s\n", buf);
+}
+
/*
* Display string in hex primitive.
*/
case AT_MAX_LIFE:
(void) printf(_("\t\tMaximum ticket life\n"));
if (vverbose) {
- print_time(&val->kdbe_val_t_u.av_max_life);
+ print_deltat(&val->kdbe_val_t_u.av_max_life);
}
break;
case AT_MAX_RENEW_LIFE:
(void) printf(_("\t\tMaximum renewable life\n"));
if (vverbose) {
- print_time(&val->kdbe_val_t_u.av_max_renew_life);
+ print_deltat(&val->kdbe_val_t_u.av_max_renew_life);
}
break;
case AT_EXP:
(void) printf(_("\tUpdate time stamp : None\n"));
else
(void) printf(_("\tUpdate time stamp : %s"),
- ctime((time_t *)&(indx_log->kdb_time.seconds)));
+ ctime_uint32(&indx_log->kdb_time.seconds));
(void) printf(_("\tAttributes changed : %d\n"),
upd.kdb_update.kdbe_t_len);
(void) printf(_("\tFirst time stamp : None\n"));
else {
(void) printf(_("\tFirst time stamp : %s"),
- ctime((time_t *)
- &(ulog->kdb_first_time.seconds)));
+ ctime_uint32(&ulog->kdb_first_time.seconds));
}
(void) printf(_("\tLast time stamp : %s\n"),
- ctime((time_t *)&(ulog->kdb_last_time.seconds)));
+ ctime_uint32(&ulog->kdb_last_time.seconds));
}
if ((!headeronly) && ulog->kdb_num) {