summaryrefslogtreecommitdiffstats
path: root/usr.bin/sockstat
diff options
context:
space:
mode:
authorkeramida <keramida@FreeBSD.org>2006-11-12 19:03:39 +0000
committerkeramida <keramida@FreeBSD.org>2006-11-12 19:03:39 +0000
commit9c9a9d1af8a3b22da68114e7bb0efd0ecc00d36a (patch)
tree8ce15ab6814291970674a29fe7b052c4b2db8576 /usr.bin/sockstat
parent1d082af7afed3c22e0c947bb378e42b9fa2fe45d (diff)
downloadFreeBSD-src-9c9a9d1af8a3b22da68114e7bb0efd0ecc00d36a.zip
FreeBSD-src-9c9a9d1af8a3b22da68114e7bb0efd0ecc00d36a.tar.gz
In revision 1.14 I broke the -4 and -6 options of sockstat(1).
Using either one of the two would result in an empty protos[] array, and no sockets were actually listed: % sockstat -4 USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS % sockstat -6 USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS % Fix this bug by tweaking appropriately the logic of handling opt_4, opt_6, opt_u and protos_defined. Submitted by: des Pointy hat: keramida
Diffstat (limited to 'usr.bin/sockstat')
-rw-r--r--usr.bin/sockstat/sockstat.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index f128d38..bd71c53 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -713,17 +713,12 @@ main(int argc, char *argv[])
if (argc > 0)
usage();
- /*
- * If protos_defined remains -1, no -P was provided, so we have to
- * set up the default protocol list in protos[] first.
- */
- if (!opt_4 && !opt_6 && !opt_u && protos_defined == -1) {
- opt_u = 1;
- protos_defined = set_default_protos();
- }
-
- if (!opt_4 && !opt_6)
+ if ((!opt_4 && !opt_6) && protos_defined != -1)
opt_4 = opt_6 = 1;
+ if (!opt_4 && !opt_6 && !opt_u)
+ opt_4 = opt_6 = opt_u = 1;
+ if ((opt_4 || opt_6) && protos_defined == -1)
+ protos_defined = set_default_protos();
if (!opt_c && !opt_l)
opt_c = opt_l = 1;
OpenPOWER on IntegriCloud