diff options
author | 2003-07-20 19:39:35 +0000 | |
---|---|---|
committer | 2003-07-20 19:39:35 +0000 | |
commit | 3a88dae60390e77b61b5bcf577baaee0a47e72d9 (patch) | |
tree | ae985b4cba699de036c936de4e642f3e6a3de86e | |
parent | Close PR 3358 by changing the loop from do {} while -> for; tdeval@ OK (diff) | |
download | wireguard-openbsd-3a88dae60390e77b61b5bcf577baaee0a47e72d9.tar.xz wireguard-openbsd-3a88dae60390e77b61b5bcf577baaee0a47e72d9.zip |
ignore backwards going entries
-rw-r--r-- | usr.sbin/ac/ac.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/ac/ac.c b/usr.sbin/ac/ac.c index a80df95c4e6..03e6ded4988 100644 --- a/usr.sbin/ac/ac.c +++ b/usr.sbin/ac/ac.c @@ -14,7 +14,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: ac.c,v 1.14 2003/06/11 23:33:24 deraadt Exp $"; +static char rcsid[] = "$Id: ac.c,v 1.15 2003/07/20 19:39:35 mickey Exp $"; #endif #include <sys/types.h> @@ -439,12 +439,15 @@ ac(FILE *fp) struct utmp_list *lp, *head = NULL; struct utmp usr; struct tm *ltm; - time_t secs = 0; + time_t secs = 0, prev = 0; int day = -1; while (fread((char *)&usr, sizeof(usr), 1, fp) == 1) { if (!FirstTime) FirstTime = usr.ut_time; + if (usr.ut_time < prev) + continue; /* broken record */ + prev = usr.ut_time; if (Flags & AC_D) { ltm = localtime(&usr.ut_time); if (day >= 0 && day != ltm->tm_yday) { |