git: bfb5947bb1e9 - main - sockstat: fix core dump
Mariusz Zaborski
oshogbo at FreeBSD.org
Fri Jun 18 16:12:23 UTC 2021
The branch main has been updated by oshogbo:
URL: https://cgit.FreeBSD.org/src/commit/?id=bfb5947bb1e92b08b07a817bd9d8e7f438115e8a
commit bfb5947bb1e92b08b07a817bd9d8e7f438115e8a
Author: Mariusz Zaborski <oshogbo at FreeBSD.org>
AuthorDate: 2021-06-18 16:03:16 +0000
Commit: Mariusz Zaborski <oshogbo at FreeBSD.org>
CommitDate: 2021-06-18 16:05:14 +0000
sockstat: fix core dump
The get_proto_type function is used before creating the Casper function.
This is why we have to distinguish when the Casper service is allocated or not.
Reported by: olivier@
Tested by: olivier@
---
usr.bin/sockstat/sockstat.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index 7dc5e4904deb..285889a07b7b 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -163,7 +163,10 @@ get_proto_type(const char *proto)
if (strlen(proto) == 0)
return (0);
- pent = cap_getprotobyname(capnetdb, proto);
+ if (capnetdb != NULL)
+ pent = cap_getprotobyname(capnetdb, proto);
+ else
+ pent = getprotobyname(proto);
if (pent == NULL) {
warn("cap_getprotobyname");
return (-1);
More information about the dev-commits-src-main
mailing list