Project

General

Profile

Bug #7302 » 5d52ffe69602c41e3fedd1d3aeb6182322ccf969.diff.txt

Andy Fiddaman, 2018-05-11 08:45 AM

 
1
diff --git a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c
2
index 475e915b2e7..5df85fd8bdf 100644
3
--- a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c
4
+++ b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c
5
@@ -5915,7 +5915,10 @@ pr_prefix6(const struct in6_addr *addr, uint_t prefixlen, char *dst,
6
 	char *cp;
7
 
8
 	if (IN6_IS_ADDR_UNSPECIFIED(addr) && prefixlen == 0) {
9
-		(void) strncpy(dst, "default", dstlen);
10
+		if (Nflag)
11
+			(void) strlcpy(dst, "::/0", dstlen);
12
+		else
13
+			(void) strlcpy(dst, "default", dstlen);
14
 		dst[dstlen - 1] = 0;
15
 		return (dst);
16
 	}
17
@@ -6048,7 +6051,14 @@ pr_net(uint_t addr, uint_t mask, char *dst, uint_t dstlen)
18
 					/* -2 == Noncontiguous mask... */
19
 
20
 	if (addr == INADDR_ANY && mask == INADDR_ANY) {
21
-		(void) strlcpy(dst, "default", dstlen);
22
+		if (Nflag) {
23
+			(void) strlcpy(dst, "0.0.0.0", dstlen);
24
+			if (CIDRflag)
25
+				(void) strlcat(dst, "/0", dstlen);
26
+		}
27
+		else {
28
+			(void) strlcpy(dst, "default", dstlen);
29
+		}
30
 		return (dst);
31
 	}
32
 
33
@@ -6131,13 +6141,21 @@ pr_netaddr(uint_t addr, uint_t mask, char *dst, uint_t dstlen)
34
 	int		prefixlen = -1;	/* -1 == Don't print prefix! */
35
 					/* -2 == Noncontiguous mask... */
36
 
37
-	addr = ntohl(addr);
38
-	mask = ntohl(mask);
39
 	if (addr == INADDR_ANY && mask == INADDR_ANY) {
40
-		(void) strlcpy(dst, "default", dstlen);
41
+		if (Nflag) {
42
+			(void) strlcpy(dst, "0.0.0.0", dstlen);
43
+			if (CIDRflag)
44
+				(void) strlcat(dst, "/0", dstlen);
45
+		}
46
+		else {
47
+			(void) strlcpy(dst, "default", dstlen);
48
+		}
49
 		return (dst);
50
 	}
51
 
52
+	addr = ntohl(addr);
53
+	mask = ntohl(mask);
54
+
55
 	if (CIDRflag)
56
 		prefixlen = v4_cidr_len(mask);
57
 
(1-1/2)