Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-8]: src/usr.bin/w Pull up following revision(s) (requested by kim...



details:   https://anonhg.NetBSD.org/src/rev/94d3f350f418
branches:  netbsd-8
changeset: 935348:94d3f350f418
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jun 30 18:50:05 2020 +0000

description:
Pull up following revision(s) (requested by kim in ticket #1564):

        usr.bin/w/w.c: revision 1.86
        usr.bin/w/w.c: revision 1.85

Compute a value for domain before comparing against it
Remove local domain always, not just when looking up addresses

diffstat:

 usr.bin/w/w.c |  54 +++++++++++++++++++++++++++---------------------------
 1 files changed, 27 insertions(+), 27 deletions(-)

diffs (93 lines):

diff -r 2f067a3cf70e -r 94d3f350f418 usr.bin/w/w.c
--- a/usr.bin/w/w.c     Tue Jun 30 17:42:57 2020 +0000
+++ b/usr.bin/w/w.c     Tue Jun 30 18:50:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: w.c,v 1.83 2016/11/16 02:03:30 christos Exp $  */
+/*     $NetBSD: w.c,v 1.83.6.1 2020/06/30 18:50:05 martin Exp $        */
 
 /*-
  * Copyright (c) 1980, 1991, 1993, 1994
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)w.c        8.6 (Berkeley) 6/30/94";
 #else
-__RCSID("$NetBSD: w.c,v 1.83 2016/11/16 02:03:30 christos Exp $");
+__RCSID("$NetBSD: w.c,v 1.83.6.1 2020/06/30 18:50:05 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -205,6 +205,18 @@
                        curtain = 0;
        }
 
+       if (!nflag) {
+               int     rv;
+               char    *p;
+
+               rv = gethostname(domain, sizeof(domain));
+               domain[sizeof(domain) - 1] = '\0';
+               if (rv < 0 || (p = strchr(domain, '.')) == 0)
+                       domain[0] = '\0';
+               else
+                       memmove(domain, p, strlen(p) + 1);
+       }
+
 #ifdef SUPPORT_UTMPX
        setutxent();
 #endif
@@ -388,18 +400,6 @@
        }
 #endif
 
-       if (!nflag) {
-               int     rv;
-               char    *p;
-
-               rv = gethostname(domain, sizeof(domain));
-               domain[sizeof(domain) - 1] = '\0';
-               if (rv < 0 || (p = strchr(domain, '.')) == 0)
-                       domain[0] = '\0';
-               else
-                       memmove(domain, p, strlen(p) + 1);
-       }
-
        for (ep = ehead; ep != NULL; ep = ep->next) {
                if (ep->tp != NULL)
                        kp = ep->tp;
@@ -652,23 +652,23 @@
        int af = m ? AF_INET6 : AF_INET;
        size_t alen = m ? sizeof(l.l6) : sizeof(l.l4);
        if (!nflag && inet_pton(af, p, &l) &&
-           (hp = gethostbyaddr((char *)&l, alen, af))) {
-               if (domain[0] != '\0') {
-                       p = hp->h_name;
-                       p += strlen(hp->h_name);
-                       p -= strlen(domain);
-                       if (p > hp->h_name &&
-                           strcasecmp(p, domain) == 0)
-                               *p = '\0';
-               }
-               p = hp->h_name;
+           (hp = gethostbyaddr((char *)&l, alen, af)))
+               strlcpy(host_buf, hp->h_name, sizeof(host_buf));
+
+       if (domain[0] != '\0') {
+               p = host_buf;
+               p += strlen(host_buf);
+               p -= strlen(domain);
+               if (p > host_buf &&
+                   strcasecmp(p, domain) == 0)
+                       *p = '\0';
        }
 
        if (x)
-               (void)snprintf(ep->host, sizeof(ep->host), "%s:%s", p, x);
+               (void)snprintf(ep->host, sizeof(ep->host), "%s:%s", host_buf,
+                   x);
        else
-
-               strlcpy(ep->host, p, sizeof(ep->host));
+               strlcpy(ep->host, host_buf, sizeof(ep->host));
 }
 
 static void



Home | Main Index | Thread Index | Old Index