diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2017-06-03 04:34:42 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2017-06-03 04:34:42 +0000 |
commit | 0ce6232d8a70af8147147483f99e57e11a90f2d0 (patch) | |
tree | bc88ecab428fa4a9df81c483cacd3408490d8331 | |
parent | 2565c4b9b64160c3c5baf381c37f1de9cb26e77c (diff) |
Avoid printing garbage when aborting a program that tries to use a
prohibited sysctl.
ok deraadt
-rw-r--r-- | sys/kern/kern_pledge.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index dae6a1bccb7..d25eb9df103 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.210 2017/05/30 15:04:45 deraadt Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.211 2017/06/03 04:34:41 tb Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org> @@ -891,6 +891,8 @@ pledge_sendfd(struct proc *p, struct file *fp) int pledge_sysctl(struct proc *p, int miblen, int *mib, void *new) { + int i; + if ((p->p_p->ps_flags & PS_PLEDGE) == 0) return (0); @@ -1053,9 +1055,11 @@ pledge_sysctl(struct proc *p, int miblen, int *mib, void *new) mib[0] == CTL_VM && mib[1] == VM_LOADAVG) return (0); - printf("%s(%d): sysctl %d: %d %d %d %d %d %d\n", - p->p_p->ps_comm, p->p_p->ps_pid, miblen, mib[0], mib[1], - mib[2], mib[3], mib[4], mib[5]); + printf("%s(%d): sysctl %d:", p->p_p->ps_comm, p->p_p->ps_pid, miblen); + for (i = 0; i < miblen; i++) + printf(" %d", mib[i]); + printf("\n"); + return pledge_fail(p, EINVAL, 0); } |