From owner-svn-src-all@freebsd.org Thu Aug 29 02:44:19 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9E664EDD42; Thu, 29 Aug 2019 02:44:19 +0000 (UTC) (envelope-from karels@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46Jn4g3h6Yz4408; Thu, 29 Aug 2019 02:44:19 +0000 (UTC) (envelope-from karels@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 60E16193FA; Thu, 29 Aug 2019 02:44:19 +0000 (UTC) (envelope-from karels@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7T2iJjF096396; Thu, 29 Aug 2019 02:44:19 GMT (envelope-from karels@FreeBSD.org) Received: (from karels@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7T2iJeJ096395; Thu, 29 Aug 2019 02:44:19 GMT (envelope-from karels@FreeBSD.org) Message-Id: <201908290244.x7T2iJeJ096395@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: karels set sender to karels@FreeBSD.org using -f From: Mike Karels Date: Thu, 29 Aug 2019 02:44:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351592 - head/usr.bin/w X-SVN-Group: head X-SVN-Commit-Author: karels X-SVN-Commit-Paths: head/usr.bin/w X-SVN-Commit-Revision: 351592 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Aug 2019 02:44:19 -0000 Author: karels Date: Thu Aug 29 02:44:18 2019 New Revision: 351592 URL: https://svnweb.freebsd.org/changeset/base/351592 Log: Fix address annotation in xml output from w The libxo xml feature of adding an annotation with the "original" address from the utmpx file if it is different than the final "from" field was broken by r351379. This was pointed out by the gcc error that save_p might be used uninitialized. Save the original address as needed in each entry, don't just use the last one from the previous loop. Reviewed by: marcel@ MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21390 Modified: head/usr.bin/w/w.c Modified: head/usr.bin/w/w.c ============================================================================== --- head/usr.bin/w/w.c Wed Aug 28 23:40:57 2019 (r351591) +++ head/usr.bin/w/w.c Thu Aug 29 02:44:18 2019 (r351592) @@ -118,6 +118,7 @@ static struct entry { char *args; /* arg list of interesting process */ struct kinfo_proc *dkp; /* debug option proc list */ char *from; /* "from": name or addr */ + char *save_from; /* original "from": name or addr */ } *ep, *ehead = NULL, **nextp = &ehead; #define debugproc(p) *(&((struct kinfo_proc *)p)->ki_udata) @@ -209,7 +210,6 @@ main(int argc, char *argv[]) if (*argv) sel_users = argv; - save_p = NULL; setutxent(); for (nusers = 0; (utmp = getutxent()) != NULL;) { struct addrinfo hints, *res; @@ -312,6 +312,8 @@ main(int argc, char *argv[]) ep->from = strdup(p); if ((i = strlen(p)) > fromwidth) fromwidth = i; + if (save_p != p) + ep->save_from = strdup(save_p); } endutxent(); @@ -451,8 +453,8 @@ main(int argc, char *argv[]) strncmp(ep->utmp.ut_line, "cua", 3) ? ep->utmp.ut_line : ep->utmp.ut_line + 3) : "-"); - if (save_p && save_p != p) - xo_attr("address", "%s", save_p); + if (ep->save_from) + xo_attr("address", "%s", ep->save_from); xo_emit("{:from/%-*.*s/%@**@s} ", fromwidth, fromwidth, ep->from); t = ep->utmp.ut_tv.tv_sec;