From ccbacbf0ab68441fe9ab9728d785b9417affb845 Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Tue, 11 Jan 2022 10:27:05 +0100 Subject: [PATCH] BUILD(client): Plugin framework: Pass element size to kvm_getprocs(3) on OpenBSD There is an additional `elemsize` argument (https://man.openbsd.org/kvm_getprocs.3): Only the first elemsize bytes of each array entry are returned. Complete OpenBSD signature: ``` struct kinfo_proc * kvm_getprocs(kvm_t *kd, int op, int arg, size_t elemsize, int *cnt); ``` Linux, FreeBSD and NetBSD have the same four-argument signature: ``` struct kinfo_proc * kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt); ``` Build-tested on OpenBSD 7.0-CURRENT. --- src/ProcessResolver.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ProcessResolver.cpp b/src/ProcessResolver.cpp index cacf1ba3e2..631cba2fa1 100644 --- a/src/ProcessResolver.cpp +++ b/src/ProcessResolver.cpp @@ -250,8 +250,10 @@ void ProcessResolver::doResolve() { } int n_procs; -# if defined(__NetBSD__) || defined(__OpenBSD__) +# if defined(__NetBSD__) struct kinfo_proc *procs_info = kvm_getprocs(kd, KERN_PROC_ALL, 0, &n_procs); +# elif defined(__OpenBSD__) + struct kinfo_proc *procs_info = kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(*procs_info), &n_procs); # else struct kinfo_proc *procs_info = kvm_getprocs(kd, KERN_PROC_PROC, 0, &n_procs); # endif