[Bug 279875] sockstat: segmentation fault

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 19 Jul 2024 23:04:08 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279875

--- Comment #5 from Konstantin Belousov <kib@FreeBSD.org> ---
Do you have set something that prevents visibility of processes/jails?
Like see_other_uids etc?

Anyway, please apply this debugging patch and report if the program still
SIGSEGVs with it.

diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index 73b1f00a4481..20a0a5e65e0a 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -1164,6 +1164,7 @@ displaysock(struct sock *s, int pos)
                                        f = RB_FIND(files_t, &ftree,
                                            &(struct file){ .xf_data =
                                            p->socket });
+                                       if (f != NULL)
                                        pos += xprintf("[%lu %d]",
                                            (u_long)f->xf_pid, f->xf_fd);
                                } else
@@ -1183,6 +1184,7 @@ displaysock(struct sock *s, int pos)
                                        f = RB_FIND(files_t, &ftree,
                                            &(struct file){ .xf_data =
                                            p->socket });
+                                       if (f != NULL);
                                        pos += xprintf("%s[%lu %d]",
                                            fref ? "" : ",",
                                            (u_long)f->xf_pid, f->xf_fd);

-- 
You are receiving this mail because:
You are the assignee for the bug.