summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2015-11-05 11:02:28 +0000
committerume <ume@FreeBSD.org>2015-11-05 11:02:28 +0000
commite649998b7f9113ecf9cf69627d17c953fc94655b (patch)
tree8c08cd69c1d723c3118416c1876afd5974b0b585
parent4908bcb50af132e1aa74bdb7dd23cdcf005de256 (diff)
downloadFreeBSD-src-e649998b7f9113ecf9cf69627d17c953fc94655b.zip
FreeBSD-src-e649998b7f9113ecf9cf69627d17c953fc94655b.tar.gz
Use returned network name from getnetbyaddr() correctly.
-rw-r--r--usr.bin/netstat/route.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.bin/netstat/route.c b/usr.bin/netstat/route.c
index 2ab35a0..3f6918c 100644
--- a/usr.bin/netstat/route.c
+++ b/usr.bin/netstat/route.c
@@ -637,14 +637,13 @@ netname4(in_addr_t in, in_addr_t mask)
trimdomain(cp, strlen(cp));
}
}
- inet_ntop(AF_INET, &in, nline, sizeof(line));
- if (cp != NULL) {
- if (strcpy(cp, nline) != 0)
- return (line);
+ if (cp != NULL)
strlcpy(line, cp, sizeof(line));
- } else
+ else {
+ inet_ntop(AF_INET, &in, nline, sizeof(nline));
strlcpy(line, nline, sizeof(line));
- domask(line + strlen(line), i, ntohl(mask));
+ domask(line + strlen(line), i, ntohl(mask));
+ }
return (line);
}
OpenPOWER on IntegriCloud