Date: Thu, 22 Apr 1999 22:28:27 +0200 From: Hans Huebner <hans@chaosradio.ccc.de> To: FreeBSD-gnats-submit@freebsd.org Subject: bin/11286: [patch] /usr/bin/w fails with -n flag for certain host names Message-ID: <E10aQ5D-000K49-00@berlin.ccc.de>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E10aQ5D-000K49-00>