svn rev #23928: trunk/src/ lib/krb5/krb/ slave/
tlyu@MIT.EDU
tlyu at MIT.EDU
Thu Apr 22 21:10:20 EDT 2010
http://src.mit.edu/fisheye/changelog/krb5/?cs=23928
Commit By: tlyu
Log Message:
ticket: 6698
target_version: 1.8.2
tags: pullup
Adapted patch from Jason Rogers. It wasn't complete, so this commit
fixes the other instances of the 64-bit problem.
Also fix krb5_deltat_to_str(), which would previously always return an
empty string.
Changed Files:
U trunk/src/lib/krb5/krb/str_conv.c
U trunk/src/slave/kproplog.c
Modified: trunk/src/lib/krb5/krb/str_conv.c
===================================================================
--- trunk/src/lib/krb5/krb/str_conv.c 2010-04-22 23:29:40 UTC (rev 23927)
+++ trunk/src/lib/krb5/krb/str_conv.c 2010-04-23 01:10:20 UTC (rev 23928)
@@ -300,7 +300,6 @@
* 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);
@@ -309,7 +308,6 @@
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)
@@ -319,14 +317,6 @@
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;
}
Modified: trunk/src/slave/kproplog.c
===================================================================
--- trunk/src/slave/kproplog.c 2010-04-22 23:29:40 UTC (rev 23927)
+++ trunk/src/slave/kproplog.c 2010-04-23 01:10:20 UTC (rev 23928)
@@ -74,20 +74,40 @@
}
}
+/* 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.
*/
@@ -251,13 +271,13 @@
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:
@@ -447,7 +467,7 @@
(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);
@@ -581,12 +601,11 @@
(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) {
More information about the cvs-krb5
mailing list