From owner-freebsd-bugs Wed May 6 02:12:51 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id CAA17306 for freebsd-bugs-outgoing; Wed, 6 May 1998 02:12:51 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id CAA17283 for ; Wed, 6 May 1998 02:12:42 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id CAA10045; Wed, 6 May 1998 02:10:01 -0700 (PDT) Date: Wed, 6 May 1998 02:10:01 -0700 (PDT) Message-Id: <199805060910.CAA10045@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.ORG From: A Joseph Koshy Subject: Re: bin/2832: w treats corrupted utmp as fatal error Reply-To: A Joseph Koshy Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/2832; it has been noted by GNATS. From: A Joseph Koshy To: freebsd-gnats-submit@freebsd.org, fenner@parc.xerox.com Cc: phk@freebsd.org, steve@freebsd.org Subject: Re: bin/2832: w treats corrupted utmp as fatal error Date: Wed, 06 May 1998 14:37:50 +0530 Here is a patch that fixes the problem pointed out by Steve P. This was generated against r1.25 of "w.c" i.e --current. -stable can use the same fix. Regards, Koshy -------- -------- -------- -------- -------- -------- -------- -------- # diff -u w.c-- w.c --- w.c-- Mon Sep 1 11:17:26 1997 +++ w.c Wed Sep 17 11:13:19 1997 @@ -209,6 +209,8 @@ for (nusers = 0; fread(&utmp, sizeof(utmp), 1, ut);) { if (utmp.ut_name[0] == '\0') continue; + if (!(stp = ttystat(utmp.ut_line))) + continue; ++nusers; if (wcmd == 0 || (sel_user && strncmp(utmp.ut_name, sel_user, UT_NAMESIZE) != 0)) @@ -218,7 +220,6 @@ *nextp = ep; nextp = &(ep->next); memmove(&(ep->utmp), &utmp, sizeof(struct utmp)); - stp = ttystat(ep->utmp.ut_line); ep->tdev = stp->st_rdev; #ifdef CPU_CONSDEV /* @@ -476,8 +477,10 @@ char ttybuf[MAXPATHLEN]; (void)snprintf(ttybuf, sizeof(ttybuf), "%s/%s", _PATH_DEV, line); - if (stat(ttybuf, &sb)) - err(1, "%s", ttybuf); + if (stat(ttybuf, &sb)) { + warn("%s", ttybuf); + return NULL; + } return (&sb); } -------- -------- -------- -------- -------- -------- -------- -------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message