Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jun 2021 16:12:23 GMT
From:      Mariusz Zaborski <oshogbo@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: bfb5947bb1e9 - main - sockstat: fix core dump
Message-ID:  <202106181612.15IGCNi5027542@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by oshogbo:

URL: https://cgit.FreeBSD.org/src/commit/?id=bfb5947bb1e92b08b07a817bd9d8e7f438115e8a

commit bfb5947bb1e92b08b07a817bd9d8e7f438115e8a
Author:     Mariusz Zaborski <oshogbo@FreeBSD.org>
AuthorDate: 2021-06-18 16:03:16 +0000
Commit:     Mariusz Zaborski <oshogbo@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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106181612.15IGCNi5027542>