diff --git a/usr.bin/netstat/Makefile b/usr.bin/netstat/Makefile index 7f88c3bfef64..c0a19a7c1671 100644 --- a/usr.bin/netstat/Makefile +++ b/usr.bin/netstat/Makefile @@ -11,8 +11,8 @@ CFLAGS+=-DIPSEC #.PATH: ${.CURDIR}/../../sys/netiso BINGRP= kmem BINMODE=2555 -DPADD= ${LIBKVM} ${LIBIPX} ${LIBNETGRAPH} -LDADD= -lkvm -lipx -lnetgraph +DPADD= ${LIBKVM} ${LIBIPX} ${LIBNETGRAPH} ${LIBUTIL} +LDADD= -lkvm -lipx -lnetgraph -lutil CFLAGS+=-DINET6 -DIPSEC .include diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index a2c2259e90db..b2e3c3e6f9c5 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -72,6 +72,7 @@ static const char rcsid[] = #include #include #include +#include #include #include #include @@ -716,7 +717,7 @@ inetname(inp) struct in_addr *inp; { register char *cp; - static char line[MAXHOSTNAMELEN + 1]; + static char line[MAXHOSTNAMELEN]; struct hostent *hp; struct netent *np; @@ -734,7 +735,7 @@ inetname(inp) hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET); if (hp) { cp = hp->h_name; - trimdomain(cp); + trimdomain(cp, strlen(cp)); } } } diff --git a/usr.bin/netstat/inet6.c b/usr.bin/netstat/inet6.c index 6fbb39ad07b3..0dd9e4e62f8d 100644 --- a/usr.bin/netstat/inet6.c +++ b/usr.bin/netstat/inet6.c @@ -1015,7 +1015,7 @@ inet6name(in6p) register char *cp; static char line[50]; struct hostent *hp; - static char domain[MAXHOSTNAMELEN + 1]; + static char domain[MAXHOSTNAMELEN]; static int first = 1; if (first && !nflag) { diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c index 9c128aad4fdf..5c23f3c3548a 100644 --- a/usr.bin/netstat/main.c +++ b/usr.bin/netstat/main.c @@ -702,33 +702,3 @@ usage() " netstat [-M core] [-N system] [-p protocol]"); exit(1); } - -void -trimdomain(cp) - char *cp; -{ - static char domain[MAXHOSTNAMELEN + 1]; - static int first = 1; - char *s; - - if (first) { - first = 0; - if (gethostname(domain, MAXHOSTNAMELEN) == 0 && - (s = strchr(domain, '.'))) - (void) strcpy(domain, s + 1); - else - domain[0] = 0; - } - - if (domain[0]) { - while ((cp = strchr(cp, '.'))) { - if (!strcasecmp(cp + 1, domain)) { - *cp = 0; /* hit it */ - break; - } else { - cp++; - } - } - } -} - diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h index 70bfbf0c6471..6886549f4bdd 100644 --- a/usr.bin/netstat/netstat.h +++ b/usr.bin/netstat/netstat.h @@ -61,7 +61,6 @@ int af; /* address family */ int kread __P((u_long addr, char *buf, int size)); char *plural __P((int)); char *plurales __P((int)); -void trimdomain __P((char *)); void protopr __P((u_long, char *, int)); void tcp_stats __P((u_long, char *)); diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c index 0a52e56d4f1d..e10d07a0e9ce 100644 --- a/usr.bin/netstat/route.c +++ b/usr.bin/netstat/route.c @@ -62,6 +62,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -637,7 +638,7 @@ routename(in) u_long in; { register char *cp; - static char line[MAXHOSTNAMELEN + 1]; + static char line[MAXHOSTNAMELEN]; struct hostent *hp; cp = 0; @@ -646,7 +647,7 @@ routename(in) AF_INET); if (hp) { cp = hp->h_name; - trimdomain(cp); + trimdomain(cp, strlen(cp)); } } if (cp) { @@ -715,7 +716,7 @@ netname(in, mask) u_long in, mask; { char *cp = 0; - static char line[MAXHOSTNAMELEN + 1]; + static char line[MAXHOSTNAMELEN]; struct netent *np = 0; u_long net, omask, dmask; register u_long i; @@ -729,7 +730,7 @@ netname(in, mask) np = getnetbyaddr(net, AF_INET); if (np) { cp = np->n_name; - trimdomain(cp); + trimdomain(cp, strlen(cp)); } } if (cp) @@ -753,7 +754,7 @@ netname6(sa6, mask) struct sockaddr_in6 *sa6; struct in6_addr *mask; { - static char line[MAXHOSTNAMELEN + 1]; + static char line[MAXHOSTNAMELEN]; u_char *p = (u_char *)mask; u_char *lim; int masklen, illegal = 0, flag = NI_WITHSCOPEID; @@ -816,7 +817,7 @@ char * routename6(sa6) struct sockaddr_in6 *sa6; { - static char line[MAXHOSTNAMELEN + 1]; + static char line[MAXHOSTNAMELEN]; int flag = NI_WITHSCOPEID; /* use local variable for safety */ struct sockaddr_in6 sa6_local = {AF_INET6, sizeof(sa6_local),};