From 72ba28e10a4b84b9d6d9dd1d4ffd57091bc6205e Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sun, 23 Jul 2000 03:10:02 +0000 Subject: [PATCH] (str2time_t): be more careful with strptime that might zero out the `struct tm' git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8783 ec53bebd-3082-4978-b11e-865c3cabbd6b --- kadmin/util.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kadmin/util.c b/kadmin/util.c index 7f8313910..bd2da11f5 100644 --- a/kadmin/util.c +++ b/kadmin/util.c @@ -171,7 +171,8 @@ int str2time_t (const char *str, time_t *time) { const char *p; - struct tm tm; + struct tm tm, tm2; + char *t; memset (&tm, 0, sizeof (tm)); @@ -186,11 +187,15 @@ str2time_t (const char *str, time_t *time) return -1; /* Do it on the end of the day */ - tm.tm_hour = 23; - tm.tm_min = 59; - tm.tm_sec = 59; + tm2.tm_hour = 23; + tm2.tm_min = 59; + tm2.tm_sec = 59; - strptime (p, "%H:%M:%S", &tm); + if(strptime (p, "%H:%M:%S", &tm2) != NULL) { + tm.tm_hour = tm2.tm_hour; + tm.tm_min = tm2.tm_min; + tm.tm_sec = tm2.tm_sec; + } *time = tm2time (tm, 0); return 0;