From 750c39c0497914e2380b03e278b5dd9b163debe7 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 19 Oct 2015 12:55:32 +0000 Subject: [PATCH] Print vnode type for sendfd/recvfd not file type, ok semarie --- sys/kern/kern_pledge.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index da0737821a4..9bee9f336fd 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.55 2015/10/18 20:15:10 deraadt Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.56 2015/10/19 12:55:32 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott @@ -738,7 +738,7 @@ pledge_aftersyscall(struct proc *p, int code, int error) int pledge_recvfd_check(struct proc *p, struct file *fp) { - struct vnode *vp; + struct vnode *vp = NULL; char *vtypes[] = { VTYPE_NAMES }; if ((p->p_p->ps_flags & PS_PLEDGE) == 0) @@ -759,7 +759,7 @@ pledge_recvfd_check(struct proc *p, struct file *fp) return (0); break; } - printf("recvfd type %d %s\n", fp->f_type, vtypes[fp->f_type]); + printf("recvfd type %d %s\n", fp->f_type, vp ? vtypes[vp->v_type] : ""); return pledge_fail(p, EPERM, PLEDGE_RECVFD); } @@ -769,7 +769,7 @@ pledge_recvfd_check(struct proc *p, struct file *fp) int pledge_sendfd_check(struct proc *p, struct file *fp) { - struct vnode *vp; + struct vnode *vp = NULL; char *vtypes[] = { VTYPE_NAMES }; if ((p->p_p->ps_flags & PS_PLEDGE) == 0) @@ -786,12 +786,12 @@ pledge_sendfd_check(struct proc *p, struct file *fp) return (0); case DTYPE_VNODE: vp = (struct vnode *)fp->f_data; - + if (vp->v_type != VDIR) return (0); break; } - printf("sendfd type %d %s\n", fp->f_type, vtypes[fp->f_type]); + printf("sendfd type %d %s\n", fp->f_type, vp ? vtypes[vp->v_type] : ""); return pledge_fail(p, EPERM, PLEDGE_SENDFD); } -- 2.20.1