Date: Wed, 6 May 1998 02:10:01 -0700 (PDT) From: A Joseph Koshy <koshy@india.hp.com> To: freebsd-bugs@FreeBSD.ORG Subject: Re: bin/2832: w treats corrupted utmp as fatal error Message-ID: <199805060910.CAA10045@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/2832; it has been noted by GNATS. From: A Joseph Koshy <koshy@india.hp.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199805060910.CAA10045>