Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/usr.bin/w Pull up following revision(s) (requested by kim...
details: https://anonhg.NetBSD.org/src/rev/df8d0fb280cd
branches: netbsd-9
changeset: 964042:df8d0fb280cd
user: martin <martin%NetBSD.org@localhost>
date: Sun Aug 02 09:12:54 2020 +0000
description:
Pull up following revision(s) (requested by kim in ticket #1034):
usr.bin/w/w.c: revision 1.88
usr.bin/w/w.c: revision 1.89
usr.bin/w/w.c: revision 1.90
Handle hostname from DISPLAY="[2001:db8::dead:beef]:0" or similar.
Restore ']' if not using a result from an address lookup.
Skip bracket processing if -n is used.
XXX: This could be improved to skip even more processing.
diffstat:
usr.bin/w/w.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
diffs (64 lines):
diff -r 02cafb24cf58 -r df8d0fb280cd usr.bin/w/w.c
--- a/usr.bin/w/w.c Sun Aug 02 08:49:08 2020 +0000
+++ b/usr.bin/w/w.c Sun Aug 02 09:12:54 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: w.c,v 1.84.2.2 2020/07/07 10:43:00 martin Exp $ */
+/* $NetBSD: w.c,v 1.84.2.3 2020/08/02 09:12:54 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.84.2.2 2020/07/07 10:43:00 martin Exp $");
+__RCSID("$NetBSD: w.c,v 1.84.2.3 2020/08/02 09:12:54 martin Exp $");
#endif
#endif /* not lint */
@@ -621,7 +621,7 @@
fixhost(struct entry *ep)
{
char host_buf[sizeof(ep->host)];
- char *p, *r, *x, *m;
+ char *b, *m, *p, *r, *x;
struct hostent *hp;
union {
struct in_addr l4;
@@ -650,13 +650,35 @@
x = NULL;
}
+ /*
+ * Leading '[' indicates an IP address inside brackets.
+ */
+ b = NULL;
+ if (!nflag && (*p == '[')) {
+ for (b = p++; b < &host_buf[sizeof(host_buf)]; b++)
+ if (*b == '\0' || *b == ']')
+ break;
+ if (b < &host_buf[sizeof(host_buf)] && *b == ']') {
+ *b = '\0';
+ for (x = b + 1; x < &host_buf[sizeof(host_buf)]; x++)
+ if (*x == '\0' || *x == ':')
+ break;
+ if (x < &host_buf[sizeof(host_buf)] && *x == ':')
+ *x++ = '\0';
+ } else
+ b = NULL;
+ }
+
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)))
r = hp->h_name;
- else
+ else {
+ if (b)
+ *b = ']';
r = host_buf;
+ }
if (domain[0] != '\0') {
p = r;
Home |
Main Index |
Thread Index |
Old Index