From cc6d0c93fdd66886fce3fc4321e3d57bdf24887d Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Wed, 19 May 2010 18:52:39 +0000 Subject: [PATCH] pull up r23928 from trunk ------------------------------------------------------------------------ r23928 | tlyu | 2010-04-22 21:10:20 -0400 (Thu, 22 Apr 2010) | 10 lines 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. ticket: 6698 version_fixed: 1.8.2 status: resolved git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-8@24059 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/str_conv.c | 10 ---------- src/slave/kproplog.c | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/lib/krb5/krb/str_conv.c b/src/lib/krb5/krb/str_conv.c index 1f2edcc66..6ed639245 100644 --- a/src/lib/krb5/krb/str_conv.c +++ b/src/lib/krb5/krb/str_conv.c @@ -300,7 +300,6 @@ krb5_deltat_to_string(krb5_deltat deltat, char *buffer, size_t buflen) * 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 @@ krb5_deltat_to_string(krb5_deltat deltat, char *buffer, size_t buflen) 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 @@ krb5_deltat_to_string(krb5_deltat deltat, char *buffer, size_t buflen) 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; } diff --git a/src/slave/kproplog.c b/src/slave/kproplog.c index 0134631b0..0af30d92c 100644 --- a/src/slave/kproplog.c +++ b/src/slave/kproplog.c @@ -74,20 +74,40 @@ print_flags(unsigned int flags) } } +/* 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 @@ print_attr(kdbe_val_t *val, int vverbose) 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 @@ print_update(kdb_hlog_t *ulog, uint32_t entry, unsigned int verbose) (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 @@ main(int argc, char **argv) (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) { -- 2.26.2