(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
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Assar Westerlund
					Assar Westerlund