Use a temp to convert ut_time to time_t
The localtime function takes a time_t* argument. Passing the ut_time member of the utmp struct as this argument doesn't work on 64 bit systems because the lengths of the arguments don't agree. So use a temproary variable to store the ut_time value in a time_t variable and pass the address of the time_t variable to localtime. Signed-off-by: Clark Rawlins <clark@bit63.org>
This commit is contained in:
parent
4f37273c60
commit
af2d3b48c6
|
@ -398,6 +398,7 @@ void read_wtmp()
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct utmp ut;
|
struct utmp ut;
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
|
time_t time;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
|
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
|
||||||
|
@ -418,7 +419,13 @@ void read_wtmp()
|
||||||
|
|
||||||
while (fread(&ut, sizeof(struct utmp), 1, fp) == 1)
|
while (fread(&ut, sizeof(struct utmp), 1, fp) == 1)
|
||||||
{
|
{
|
||||||
tm = localtime(&ut.ut_time);
|
/* On 64 bit systems time_t is a 64 bit integer
|
||||||
|
while ut_time is a 32 bit (unsigned) integer.
|
||||||
|
Copy the value to a time_t value so the pointer
|
||||||
|
types agree in the call to localtime.
|
||||||
|
*/
|
||||||
|
time = ut.ut_time;
|
||||||
|
tm = localtime(&time);
|
||||||
|
|
||||||
if (tm->tm_year != now.tm_year || tm->tm_yday != now.tm_yday)
|
if (tm->tm_year != now.tm_year || tm->tm_yday != now.tm_yday)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue