From bfb5947bb1e92b08b07a817bd9d8e7f438115e8a Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski Date: Fri, 18 Jun 2021 18:03:16 +0200 Subject: [PATCH] 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);