From owner-freebsd-bugs Thu Apr 22 13:32:34 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 69D7E159C3 for ; Thu, 22 Apr 1999 13:32:32 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.2/8.9.2) id NAA99950; Thu, 22 Apr 1999 13:30:03 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from berlin.ccc.de (berlin.ccc.de [195.21.255.248]) by hub.freebsd.org (Postfix) with ESMTP id 23A4514EBA for ; Thu, 22 Apr 1999 13:31:40 -0700 (PDT) (envelope-from hans@chaosradio.ccc.de) Received: from hans by berlin.ccc.de with local (Exim 2.05 #1) id 10aQ5D-000K49-00 for FreeBSD-gnats-submit@freebsd.org; Thu, 22 Apr 1999 22:28:27 +0200 Message-Id: Date: Thu, 22 Apr 1999 22:28:27 +0200 From: Hans Huebner Reply-To: hans@chaosradio.ccc.de To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/11286: [patch] /usr/bin/w fails with -n flag for certain host names Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 11286 >Category: bin >Synopsis: [patch] /usr/bin/w fails with -n flag for certain host names >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Apr 22 13:30:02 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Hans Huebner >Release: FreeBSD 3.1-STABLE i386 >Organization: Chaos Computer Club Berlin >Environment: -STABLE as of this week. >Description: The w command has a flag -n, which makes it print IP addresses instead of host names in the FROM field. If a user's entry in the utmp file contains a hostname with 16 chars, w fails to translate it back to an IP adress. >How-To-Repeat: "w -n" on a system with someone logged in from a host whose name is 16 characters long. >Fix: Index: w.c =================================================================== RCS file: /usr/cvs/src/usr.bin/w/w.c,v retrieving revision 1.32 diff -u -r1.32 w.c --- w.c 1999/01/10 15:28:37 1.32 +++ w.c 1999/04/22 20:16:12 @@ -337,7 +337,10 @@ } for (ep = ehead; ep != NULL; ep = ep->next) { - p = *ep->utmp.ut_host ? ep->utmp.ut_host : "-"; + char host_buf[UT_HOSTSIZE+1]; + host_buf[UT_HOSTSIZE] = '\0'; + strncpy(host_buf, ep->utmp.ut_host, UT_HOSTSIZE); + p = *host_buf ? host_buf : "-"; if ((x = strchr(p, ':')) != NULL) *x++ = '\0'; if (!nflag && isdigit(*p) && >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message