Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site allegra.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mp From: mp@allegra.UUCP (Mark Plotnick) Newsgroups: net.bugs.4bsd Subject: ruptime reports 0 users Message-ID: <5444@allegra.UUCP> Date: Mon, 25-Nov-85 00:11:19 EST Article-I.D.: allegra.5444 Posted: Mon Nov 25 00:11:19 1985 Date-Received: Mon, 25-Nov-85 08:14:25 EST Organization: AT&T Bell Laboratories, Murray Hill Lines: 45 ruptime may claim that a machine with lots of users on it has 0 users. This is because it reads only the first 1K bytes of a whod file into a buffer, and assumes that it can read an array of structures backwards from the end of the buffer. What it gets, if the whod file is big enough, is a bunch of garbled structures. Here are the minimum changes necessary to stop it from getting confused; a cleaner fix would involve rewriting it to look more like rwho.c. *** ruptime.1.1 Sun Nov 24 16:58:43 1985 --- ruptime.1.2 Sun Nov 24 16:58:44 1985 *************** *** 36,38 int f, i, t; ! char buf[BUFSIZ]; int cc; register struct hs *hsp = hs; --- 36,38 ----- int f, i, t; ! char buf[sizeof (struct whod)]; int cc; register struct hs *hsp = hs; *************** *** 86,88 if (f > 0) { ! cc = read(f, buf, BUFSIZ); if (cc >= WHDRSIZE) { --- 86,88 ----- if (f > 0) { ! cc = read(f, buf, sizeof buf); if (cc >= WHDRSIZE) { *************** *** 88,89 if (cc >= WHDRSIZE) { hsp->hs_wd = (struct whod *)malloc(WHDRSIZE); --- 88,91 ----- if (cc >= WHDRSIZE) { + /* first, chop off any incomplete entry */ + cc -= (cc - WHDRSIZE) % sizeof (struct whoent); hsp->hs_wd = (struct whod *)malloc(WHDRSIZE); Mark Plotnick Department of remote control allegra!mp