summaryrefslogtreecommitdiff
path: root/lib/libkvm
diff options
context:
space:
mode:
authorChristian Weisgerber <naddy@cvs.openbsd.org>2020-10-14 19:28:23 +0000
committerChristian Weisgerber <naddy@cvs.openbsd.org>2020-10-14 19:28:23 +0000
commit463f266f080fff39e2821ba2b660e3d0e1630aad (patch)
tree2f3eda62dd1454489ab12371182cee7bb696173b /lib/libkvm
parenta2b8d544aa77114ea1605fa6bb4773636dc91f20 (diff)
Accommodate POSIX basename(3) that takes a non-const parameter and
may modify the string buffer. ok millert@
Diffstat (limited to 'lib/libkvm')
-rw-r--r--lib/libkvm/kvm.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index 610173686e3..63e67fd4b95 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm.c,v 1.66 2019/06/28 13:32:42 deraadt Exp $ */
+/* $OpenBSD: kvm.c,v 1.67 2020/10/14 19:28:22 naddy Exp $ */
/* $NetBSD: kvm.c,v 1.43 1996/05/05 04:31:59 gwr Exp $ */
/*-
@@ -676,12 +676,13 @@ static int
kvm_dbopen(kvm_t *kd, const char *uf)
{
char dbversion[_POSIX2_LINE_MAX], kversion[_POSIX2_LINE_MAX];
- char dbname[PATH_MAX];
+ char dbname[PATH_MAX], ufbuf[PATH_MAX];
struct nlist nitem;
size_t dbversionlen;
DBT rec;
- uf = basename(uf);
+ strlcpy(ufbuf, uf, sizeof(ufbuf));
+ uf = basename(ufbuf);
(void)snprintf(dbname, sizeof(dbname), "%skvm_%s.db", _PATH_VARDB, uf);
kd->db = dbopen(dbname, O_RDONLY, 0, DB_HASH, NULL);