From 44dfbf20b41ca69c6fb308df2607ddc79c86e6ae Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 22 Feb 2022 03:34:51 +0000 Subject: [PATCH] The FILL_KPROC() macro should be useable in situations where sys/param.h hasn't been included, so the use of MIN() is not legit, and a local version is required. --- sys/sys/sysctl.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index 6e34020ea48..5a47934ac82 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.224 2022/02/14 18:09:08 rob Exp $ */ +/* $OpenBSD: sysctl.h,v 1.225 2022/02/22 03:34:51 deraadt Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -580,6 +580,8 @@ struct kinfo_vmentry { #define PTRTOINT64(_x) ((u_int64_t)(u_long)(_x)) +#define _FILL_KPROC_MIN(a,b) (((a)<(b))?(a):(b)) + #define FILL_KPROC(kp, copy_str, p, pr, uc, pg, paddr, \ praddr, sess, vm, lim, sa, isthread, show_addresses) \ do { \ @@ -610,7 +612,7 @@ do { \ (kp)->p_svgid = (uc)->cr_svgid; \ \ memcpy((kp)->p_groups, (uc)->cr_groups, \ - MIN(sizeof((kp)->p_groups), sizeof((uc)->cr_groups))); \ + _FILL_KPROC_MIN(sizeof((kp)->p_groups), sizeof((uc)->cr_groups))); \ (kp)->p_ngroups = (uc)->cr_ngroups; \ \ (kp)->p_jobc = (pg)->pg_jobc; \ @@ -652,7 +654,7 @@ do { \ strlcpy((kp)->p_emul, "native", sizeof((kp)->p_emul)); \ strlcpy((kp)->p_comm, (pr)->ps_comm, sizeof((kp)->p_comm)); \ strlcpy((kp)->p_login, (sess)->s_login, \ - MIN(sizeof((kp)->p_login), sizeof((sess)->s_login))); \ + _FILL_KPROC_MIN(sizeof((kp)->p_login), sizeof((sess)->s_login))); \ \ if ((sess)->s_ttyvp) \ (kp)->p_eflag |= EPROC_CTTY; \ -- 2.20.1