From 39cbba3c6e68874f2bedca06e9b13bea6e995fc2 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 13 Aug 2019 21:36:18 +0000 Subject: config -eu uses a second copy of the nlist array[], which should never become different or the #define's for the slots could diverge. To avoid this, make one a copy of the other at runtime. --- usr.sbin/config/ukc.c | 8 +++++++- usr.sbin/config/ukc.h | 24 +----------------------- 2 files changed, 8 insertions(+), 24 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/config/ukc.c b/usr.sbin/config/ukc.c index 7fcc46a484c..def912035b1 100644 --- a/usr.sbin/config/ukc.c +++ b/usr.sbin/config/ukc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukc.c,v 1.24 2019/08/11 17:08:33 deraadt Exp $ */ +/* $OpenBSD: ukc.c,v 1.25 2019/08/13 21:36:18 deraadt Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -40,6 +40,7 @@ #define UKC_MAIN #include "ukc.h" #include "exec.h" +#include "config.h" void init(void); __dead void usage(void); @@ -74,6 +75,11 @@ ukc(char *file, char *outfile, int uflag, int force) errx(1, "nlist: %s", file); if (uflag) { + struct nlist *knl; + + knl = emalloc(sizeof(nl)); + memcpy(knl, &nl, sizeof nl); + if ((kd = kvm_openfiles(NULL,NULL,NULL,O_RDONLY, errbuf)) == 0) errx(1, "kvm_openfiles: %s", errbuf); diff --git a/usr.sbin/config/ukc.h b/usr.sbin/config/ukc.h index b8ef2463caf..071437b9b70 100644 --- a/usr.sbin/config/ukc.h +++ b/usr.sbin/config/ukc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ukc.h,v 1.15 2019/08/11 17:08:33 deraadt Exp $ */ +/* $OpenBSD: ukc.h,v 1.16 2019/08/13 21:36:18 deraadt Exp $ */ /* * Copyright (c) 1999-2001 Mats O Jansson. All rights reserved. @@ -71,28 +71,6 @@ struct nlist nl[] = { { "_nkmempages" }, { NULL }, }; -struct nlist knl[] = { - { "_locnames" }, - { "_locnamp" }, - { "_cfroots" }, - { "_cfroots_size" }, - { "_pv_size" }, - { "_pv" }, - { "_cfdata" }, - { "_kernel_text" }, - { "_version" }, - { "_extraloc" }, - { "_rextraloc" }, - { "_textraloc" }, - { "_userconf_histlen" }, - { "_userconf_history" }, - { "_tz" }, - { "_pdevnames" }, - { "_pdevnames_size" }, - { "_pdevinit" }, - { "_nkmempages" }, - { NULL }, -}; int maxdev = 0; int totdev = 0; int maxpseudo = 0; -- cgit v1.2.3-59-g8ed1b