[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

/usr/bin/last calculates incorrect total time



/usr/bin/last calculates incorrect total time.

Environment:
 OpenBSD 3.4-stable, i386

How to repeat:
 root_(_at_)_typhoon:~# last -c | tail -n 3
 Total time: 8430 days, 23:12
 wtmp begins Sat Jan  3 04:06 2004

How to fix:
--- usr.bin/last/last.c Fri Aug 15 01:02:09 2003
+++ usr.bin/last/last.c Wed Jan  7 21:01:34 2004
@@ -231,7 +231,7 @@
        TTY     *T;                     /* tty list entry */
        struct stat     stb;            /* stat of file for size */
        time_t  delta;                  /* time difference */
-       time_t  total;
+       time_t  total = 0;
        off_t   bl;
        int     timesize;               /* how long time string gonna be */
        int     bytes, wfd;

Result:
 root_(_at_)_typhoon:~# last -c | tail -n 3
 Total time: 6 days, 16:55
 wtmp begins Sat Jan  3 04:06 2004

--
ilya voronin <ivoronin_(_at_)_trancom_(_dot_)_ru>