Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/netstat in getpcblist_sysctl() if sysctlnametomib() ...



details:   https://anonhg.NetBSD.org/src/rev/a5083b28ac8d
branches:  trunk
changeset: 349775:a5083b28ac8d
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Dec 23 06:22:00 2016 +0000

description:
in getpcblist_sysctl() if sysctlnametomib() fails, return NULL and
set *len = 0, rather than bailing.  now "netstat" doesn't give up
early on kernels without INET6.

diffstat:

 usr.bin/netstat/inet.c |  14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diffs (43 lines):

diff -r 0ae33ab0ab7e -r a5083b28ac8d usr.bin/netstat/inet.c
--- a/usr.bin/netstat/inet.c    Fri Dec 23 06:01:41 2016 +0000
+++ b/usr.bin/netstat/inet.c    Fri Dec 23 06:22:00 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inet.c,v 1.106 2015/02/08 15:09:45 christos Exp $      */
+/*     $NetBSD: inet.c,v 1.107 2016/12/23 06:22:00 mrg Exp $   */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "from: @(#)inet.c       8.4 (Berkeley) 4/20/94";
 #else
-__RCSID("$NetBSD: inet.c,v 1.106 2015/02/08 15:09:45 christos Exp $");
+__RCSID("$NetBSD: inet.c,v 1.107 2016/12/23 06:22:00 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -88,6 +88,8 @@
 #include <stdlib.h>
 #include <err.h>
 #include <util.h>
+#include <errno.h>
+
 #include "netstat.h"
 #include "vtw.h"
 #include "prog_ops.h"
@@ -240,8 +242,14 @@
                err(1, "asprintf");
 
        /* get dynamic pcblist node */
-       if (sysctlnametomib(mibname, mib, &namelen) == -1)
+       if (sysctlnametomib(mibname, mib, &namelen) == -1) {
+               if (errno == ENOENT) {
+                       *len = 0;
+                       return NULL;
+               }
+                       
                err(1, "sysctlnametomib: %s", mibname);
+       }
 
        free(mibname);
 



Home | Main Index | Thread Index | Old Index