summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflipk <flipk@openbsd.org>1997-03-03 03:25:10 +0000
committerflipk <flipk@openbsd.org>1997-03-03 03:25:10 +0000
commit5ac84c996e24c5005ad9be09f8921e1502b0cb96 (patch)
treee400fb3db01d10d7d7ee46a0fa8215406f9b76ed
parentfix typo (diff)
downloadwireguard-openbsd-5ac84c996e24c5005ad9be09f8921e1502b0cb96.tar.xz
wireguard-openbsd-5ac84c996e24c5005ad9be09f8921e1502b0cb96.zip
don't try to fseek to before the beginning of the file;
showed up after the fix to sys_lseek concerning negative offsets. avoids '/var/account/acct: Invalid argument' messages.
-rw-r--r--usr.bin/lastcomm/lastcomm.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/lastcomm/lastcomm.c b/usr.bin/lastcomm/lastcomm.c
index f47688fab0a..66478b358ad 100644
--- a/usr.bin/lastcomm/lastcomm.c
+++ b/usr.bin/lastcomm/lastcomm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lastcomm.c,v 1.4 1997/01/15 23:42:41 millert Exp $ */
+/* $OpenBSD: lastcomm.c,v 1.5 1997/03/03 03:25:10 flipk Exp $ */
/* $NetBSD: lastcomm.c,v 1.9 1995/10/22 01:43:42 ghudson Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)lastcomm.c 8.2 (Berkeley) 4/29/95";
#endif
-static char rcsid[] = "$OpenBSD: lastcomm.c,v 1.4 1997/01/15 23:42:41 millert Exp $";
+static char rcsid[] = "$OpenBSD: lastcomm.c,v 1.5 1997/03/03 03:25:10 flipk Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -128,8 +128,6 @@ main(argc, argv)
if (fseek(fp, 2 * -(long)sizeof(struct acct), SEEK_CUR) == -1)
err(1, "%s", acctfile);
- if (size == 0)
- break;
size -= sizeof(struct acct);
if (ab.ac_comm[0] == '\0') {
@@ -154,6 +152,9 @@ main(argc, argv)
delta / SECSPERHOUR,
fmod(delta, SECSPERHOUR) / SECSPERMIN,
fmod(delta, SECSPERMIN));
+
+ if (size == 0)
+ break;
}
exit(0);
}