diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2024-07-20 00:30:55 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2024-07-28 15:02:45 +0000 |
commit | 7d1e4b7bf299dbf2319c969357cd1545ad81c8a6 (patch) | |
tree | c3b112a81ef0ac9cb660ee2dfc0655bb97f6ea48 | |
parent | 806fbbbbe5d2eb5decfaafba6deb94534655cc8e (diff) |
sockstat(1): tolerate situation where file info cannot be fetched
PR: 279875
(cherry picked from commit 35f4984343229545881a324a00cdbb3980d675ce)
-rw-r--r-- | usr.bin/sockstat/sockstat.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index 52c494f03045..56f107b5cdaf 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -1165,8 +1165,11 @@ displaysock(struct sock *s, int pos) f = RB_FIND(files_t, &ftree, &(struct file){ .xf_data = p->socket }); - pos += xprintf("[%lu %d]", - (u_long)f->xf_pid, f->xf_fd); + if (f != NULL) { + pos += xprintf("[%lu %d]", + (u_long)f->xf_pid, + f->xf_fd); + } } else pos += printaddr(&p->laddr->address); } @@ -1184,9 +1187,12 @@ displaysock(struct sock *s, int pos) f = RB_FIND(files_t, &ftree, &(struct file){ .xf_data = p->socket }); - pos += xprintf("%s[%lu %d]", - fref ? "" : ",", - (u_long)f->xf_pid, f->xf_fd); + if (f != NULL) { + pos += xprintf("%s[%lu %d]", + fref ? "" : ",", + (u_long)f->xf_pid, + f->xf_fd); + } ref = p->faddr->nextref; fref = false; } |