From nobody@FreeBSD.org  Wed Mar 24 07:10:22 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 546C516A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 24 Mar 2004 07:10:22 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 4EA4343D3F
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 24 Mar 2004 07:10:22 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i2OFAL72084411
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 24 Mar 2004 07:10:21 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i2OFALtm084410;
	Wed, 24 Mar 2004 07:10:21 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200403241510.i2OFALtm084410@www.freebsd.org>
Date: Wed, 24 Mar 2004 07:10:21 -0800 (PST)
From: MUKAIGAITO Takeya <mkgt@box.email.ne.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: lastcomm dosen't accept arguments
X-Send-Pr-Version: www-2.3

>Number:         64658
>Category:       bin
>Synopsis:       lastcomm dosen't accept arguments
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 24 07:20:20 PST 2004
>Closed-Date:    Thu May 20 12:49:14 PDT 2004
>Last-Modified:  Thu May 20 12:49:14 PDT 2004
>Originator:     MUKAIGAITO Takeya
>Release:        5.2 Current
>Organization:
>Environment:
FreeBSD belfort 5.2-CURRENT FreeBSD 5.2-CURRENT #1: Fri Mar 19 16:31:28 JST 2004     root@belfort:/usr/obj/usr/src/sys/belfort  i386
>Description:
The lastcomm command dosen't accept arguments.

When I run lastcomm with an argument, it fails. e.g.

bash-2.05b# lastcomm who
lastcomm: /var/account/acct: Unknown error: 0
bash-2.05b#

>How-To-Repeat:
$ lastcomm command

>Fix:
When i run the lastcomm with some argments,
the next comparison in the main loop may become true.

if (*argv && !requested(argv, &ab))
	continue;

It would `continue' without fseeking the acct file.

The easiest and worst fix:

--- lastcomm.c.orig	Tue Jan 28 03:16:32 2003
+++ lastcomm.c	Wed Mar 24 18:57:09 2004
@@ -167,7 +167,7 @@
 				if (!isprint(*p))
 					*p = '?';
 		if (*argv && !requested(argv, &ab))
-			continue;
+			goto L1;;
 
 		(void)printf("%-*.*s %-7s %-*s %-*s",
 			     AC_COMM_LEN, AC_COMM_LEN, ab.ac_comm,
@@ -210,7 +210,7 @@
 			(void)printf(" %.16s", ctime(&t));
 		}
 		printf("\n");
-
+L1:
 		if (size == 0)
 			break;
 		size -= sizeof(struct acct);



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: hmp 
State-Changed-When: Thu May 20 12:48:26 PDT 2004 
State-Changed-Why:  
A more complete fix was committed (see bin/66765).  Thanks! 


http://www.freebsd.org/cgi/query-pr.cgi?pr=64658 
>Unformatted:
