Subject: bin/4067: ac -p prints user logged via network multiple times
To: None <gnats-bugs@gnats.netbsd.org>
From: Hubert Feyrer <feyrer@feyrer.net>
List: netbsd-bugs
Date: 08/30/1997 21:42:35
>Number:         4067
>Category:       bin
>Synopsis:       ac -p prints user logged via network multiple times
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 30 12:50:00 1997
>Last-Modified:
>Originator:     Hubert Feyrer
>Organization:
Hubert Feyrer <hubert.feyrer@rz.uni-regensburg.de>
>Release:        970815 snapshot
>Environment:
	
System: NetBSD miyu 1.2G NetBSD 1.2G (MIYU) #4: Sat Aug 30 01:29:51 MEST 1997 feyrer@miyu:/usr/src12G-970815/sys/arch/i386/compile/MIYU i386


>Description:
	'ac -p' prints some users several times.

>How-To-Repeat:
	Take a machine which has users logged in via the net, then type:
	ac -p

>Fix:
	ac keeps login usernames in a char name[UT_NAMESIZE+1] but
	compares login names on length sizeof(name), thus, one too 
	much, resulting in some weirdness. :)
	
	--- /usr/src/usr.sbin/ac/ac.c.orig	Sat Aug 30 20:33:37 1997
	+++ /usr/src/usr.sbin/ac/ac.c	Sat Aug 30 21:34:58 1997
	@@ -238,7 +238,7 @@
	 	struct user_list *up;
	 
	 	for (up = head; up != NULL; up = up->next) {
	-		if (strncmp(up->name, name, sizeof (up->name)) == 0) {
	+		if (strncmp(up->name, name, sizeof (up->name) - 1) == 0) {
	 			up->secs += secs;
	 			Total += secs;
	 			return head;
>Audit-Trail:
>Unformatted: