From: flipk Date: Mon, 3 Mar 1997 03:25:10 +0000 (+0000) Subject: don't try to fseek to before the beginning of the file; X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5ac84c996e24c5005ad9be09f8921e1502b0cb96;p=openbsd 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. --- 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 @@ -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); }