Module Name: src Committed By: yamt Date: Sat Nov 19 08:56:20 UTC 2022
Modified Files: src/usr.bin/netstat: bpf.c Log Message: netstat/bpf.c: Don't print garbage for stale pid To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.bin/netstat/bpf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/netstat/bpf.c diff -u src/usr.bin/netstat/bpf.c:1.16 src/usr.bin/netstat/bpf.c:1.17 --- src/usr.bin/netstat/bpf.c:1.16 Thu Sep 1 10:10:20 2022 +++ src/usr.bin/netstat/bpf.c Sat Nov 19 08:56:20 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.16 2022/09/01 10:10:20 msaitoh Exp $ */ +/* $NetBSD: bpf.c,v 1.17 2022/11/19 08:56:20 yamt Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -162,8 +162,13 @@ bpf_dump(const char *bpfif) name[namelen++] = szproc; name[namelen++] = 1; + /* + * Note: The sysctl succeeds (returns 0) even if it failed + * to find the process. The szproc check below is to detect + * that case. + */ if (prog_sysctl(&name[0], namelen, &p, &szproc, - NULL, 0) == -1) + NULL, 0) == -1 || szproc != sizeof(p)) printf("-\n"); else printf("%s\n", p.p_comm);