Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/pmap deal with variable length namecache entries.



details:   https://anonhg.NetBSD.org/src/rev/6acef3825a01
branches:  trunk
changeset: 454325:6acef3825a01
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Sep 13 13:55:24 2019 +0000

description:
deal with variable length namecache entries.

diffstat:

 usr.bin/pmap/main.c |  21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r 72dc9f6dc866 -r 6acef3825a01 usr.bin/pmap/main.c
--- a/usr.bin/pmap/main.c       Fri Sep 13 13:39:13 2019 +0000
+++ b/usr.bin/pmap/main.c       Fri Sep 13 13:55:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.26 2015/12/14 03:15:10 christos Exp $ */
+/*     $NetBSD: main.c,v 1.27 2019/09/13 13:55:24 christos Exp $ */
 
 /*
  * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.26 2015/12/14 03:15:10 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.27 2019/09/13 13:55:24 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -467,7 +467,12 @@
 void
 load_name_cache(kvm_t *kd)
 {
-       struct namecache _ncp, *ncp, *oncp;
+       struct namecache *ncp, *oncp;
+       union {
+               struct namecache ncp;
+               char buf[sizeof(*ncp) + USHRT_MAX];
+       } _n;
+#define _ncp _n.ncp
        struct nchashhead _ncpp, *ncpp; 
        u_long lnchash;
        size_t nchash, i;
@@ -485,11 +490,19 @@
                ncpp = &nchashtbl[i];
                oncp = NULL;
                LIST_FOREACH(ncp, ncpp, nc_hash) {
+                       size_t len;
+
                        if (ncp == oncp ||
                            ncp == (void*)0xdeadbeef)
                                break;
                        oncp = ncp;
-                       _KDEREF(kd, (u_long)ncp, &_ncp, sizeof(*ncp));
+                       len = NCHNAMLEN;
+again:
+                       _KDEREF(kd, (u_long)ncp, &_ncp, (len + sizeof(*ncp)));
+                       if (_ncp.nc_nlen > len && _ncp.nc_nlen < 1024) {
+                               len = _ncp.nc_nlen;
+                               goto again;
+                       }
                        ncp = &_ncp;
                        if (ncp->nc_nlen > 0) {
                                if (ncp->nc_nlen > 2 ||



Home | Main Index | Thread Index | Old Index