summaryrefslogtreecommitdiffstats
path: root/lib/libkvm/kvm_file2.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2010-06-29 16:39:22 +0000
committerguenther <guenther@openbsd.org>2010-06-29 16:39:22 +0000
commitd8035eb33180d1cf5de0fa91afe9ef554e5020dd (patch)
tree015ebd2319253a5c10dbc3dc7a805e4bdd081076 /lib/libkvm/kvm_file2.c
parentAdd the new schema parser. (diff)
downloadwireguard-openbsd-d8035eb33180d1cf5de0fa91afe9ef554e5020dd.tar.xz
wireguard-openbsd-d8035eb33180d1cf5de0fa91afe9ef554e5020dd.zip
Fail instead of lying if a process asks sysctl()'s KERN_PROC2 or
KERN_FILE2 (or their libkvm wrappers) for more information than the running implementation knows how to provide. ok millert@ deraadt@
Diffstat (limited to 'lib/libkvm/kvm_file2.c')
-rw-r--r--lib/libkvm/kvm_file2.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libkvm/kvm_file2.c b/lib/libkvm/kvm_file2.c
index 0df59df095a..2af3d7702fa 100644
--- a/lib/libkvm/kvm_file2.c
+++ b/lib/libkvm/kvm_file2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_file2.c,v 1.14 2010/01/10 03:37:50 guenther Exp $ */
+/* $OpenBSD: kvm_file2.c,v 1.15 2010/06/29 16:39:23 guenther Exp $ */
/*
* Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -172,6 +172,11 @@ kvm_getfile2(kvm_t *kd, int op, int arg, size_t esize, int *cnt)
*cnt = size / esize;
return ((struct kinfo_file2 *)kd->filebase);
} else {
+ if (esize > sizeof(struct kinfo_file2)) {
+ _kvm_syserr(kd, kd->program,
+ "kvm_getfile2: unknown fields requested: libkvm out of date?");
+ return (NULL);
+ }
deadway:
switch (op) {
case KERN_FILE_BYFILE: