git: 369ef36d0857 - releng/15.0 - sockstat: fix column length for PROTO
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 23 Oct 2025 23:37:21 UTC
The branch releng/15.0 has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=369ef36d0857f59a2178db707d963daf6ecfcccd
commit 369ef36d0857f59a2178db707d963daf6ecfcccd
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2025-10-20 14:26:52 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-23 23:32:34 +0000
sockstat: fix column length for PROTO
The computation of the length was not taking into account that IPv6
endpoints, which are not IPv6 only, have a suffix of 46.
For UDP and TCP this bug was not relevant, since tcp46 and udp46
has the same length as PROTO, but sctp46 is longer. Upcoming
udplite support will also be affected.
Approved by: re (cperciva)
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D53212
(cherry picked from commit 4ee0ddae1dab05dd8e3f273d861043c3e2919f23)
(cherry picked from commit 8c197879bf55dd9bdec84397fc29c3abcf959840)
---
usr.bin/sockstat/main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c
index d1ea6b1bc958..abb73acafc2f 100644
--- a/usr.bin/sockstat/main.c
+++ b/usr.bin/sockstat/main.c
@@ -1196,7 +1196,9 @@ calculate_sock_column_widths(struct col_widths *cw, struct sock *s)
first = true;
len = strlen(s->protoname);
- if (s->vflag & (INP_IPV4 | INP_IPV6))
+ if (s->vflag & INP_IPV4)
+ len += 1;
+ if (s->vflag & INP_IPV6)
len += 1;
cw->proto = MAX(cw->proto, len);