diff --git a/src/ptserver/display.c b/src/ptserver/display.c index 64fcf6b8f2..779dd33720 100644 --- a/src/ptserver/display.c +++ b/src/ptserver/display.c @@ -28,9 +28,13 @@ pr_TimeToString(time_t clock) if (!this_year) { time_t now = time(0); tm = localtime(&now); + if (!tm) + return "time-not-set "; this_year = tm->tm_year; } tm = localtime(&clock); + if (!tm) + return "time-not-set "; if (tm->tm_year != this_year) strftime(buffer, 32, "%m/%d/%Y %H:%M:%S", tm); else diff --git a/src/util/ktime.c b/src/util/ktime.c index 4df420df3d..7eb512197d 100644 --- a/src/util/ktime.c +++ b/src/util/ktime.c @@ -390,6 +390,8 @@ ktime_next(struct ktime * aktime, afs_int32 afrom) * daylight savings time day */ for (probe = start;; probe += (23 * 3600)) { tsp = localtime(&probe); /* find out what UTC time "probe" is */ + if (!tsp) + return KTIME_NEVERTIME; tdate.year = tsp->tm_year; tdate.month = tsp->tm_mon + 1; @@ -405,7 +407,10 @@ ktime_next(struct ktime * aktime, afs_int32 afrom) continue; /* "probe" time is already past */ if ((tmask & KTIME_DAY) == 0) /* don't care about day, we're done */ break; + tsp = localtime(&time_next); + if (!tsp) + return KTIME_NEVERTIME; if (tsp->tm_wday == aktime->day) break; /* day matches, we're done */ } @@ -637,6 +642,8 @@ ktime_InterpretDate(struct ktime_date * akdate) while (tbit > 0) { temp = tresult + tbit; /* see if adding this bit keeps us < akdate */ tsp = localtime(&temp); + if (!tsp) + return KTIMEDATE_NEVERDATE; tsp->tm_mon++; if (KDateCmp(akdate, tsp) >= 0) { /* if temp still represents earlier than date than we're searching