[go: up one dir, main page]

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2026-01-06 22:19:57 +0000
committerAlan Somers <asomers@FreeBSD.org>2026-01-07 14:35:13 +0000
commit3b6615ec0332f901fcc9e9307f78717424f09c1e (patch)
tree14acaabd7989a28c8302a0e81c4be2f915e87808
parentd07198ff72aeddc5a884cfb81b22c22f2abf88f6 (diff)
netstat: fix a segfault with --libxoHEADmain
Fix a segfault when printing the "protocol" field. The field-format and encoding-format were expecting different numbers of arguments. Also, fix the width of the tcp-state field in encoded output. PR: 292228 Fixes: c2b08c13c20 netstat: add support for UDP-Lite endpoints MFC after: 1 week Sponsored by: ConnectWise Reviewed by: tuexen, js, des Differential Revision: https://reviews.freebsd.org/D54567
-rw-r--r--usr.bin/netstat/inet.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index dee245b63a87..6e4811480237 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -394,11 +394,10 @@ protopr(u_long off, const char *name, int af1, int proto)
if (istcp && (tp->t_flags & TF_TOE) != 0)
xo_emit("{:protocol/%-3.3s%-6.6s/%s%s} ", "toe", vchar);
else {
- int len;
+ int l = max (2, 9 - strlen(name));
- len = max (2, 9 - strlen(name));
- xo_emit("{:protocol/%.7s%-*.*s/%s%s} ", name, len, len,
- vchar);
+ xo_emit("{d:protocol/%.7s%-*.*s} ", name, l, l, vchar);
+ xo_emit("{e:protocol/%s%s}", name, vchar);
}
if (Lflag) {
char buf1[33];
@@ -523,9 +522,9 @@ protopr(u_long off, const char *name, int af1, int proto)
}
if (istcp && !Lflag && !xflag && !Tflag && !Rflag) {
if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES)
- xo_emit("{:tcp-state/%-11d}", tp->t_state);
+ xo_emit("{:tcp-state/%-11d/%d}", tp->t_state);
else {
- xo_emit("{:tcp-state/%-11s}",
+ xo_emit("{:tcp-state/%-11s/%s}",
tcpstates[tp->t_state]);
#if defined(TF_NEEDSYN) && defined(TF_NEEDFIN)
/* Show T/TCP `hidden state' */