diff options
author | 2002-05-02 00:36:04 +0000 | |
---|---|---|
committer | 2002-05-02 00:36:04 +0000 | |
commit | 2816a665af4083acdfc1065badc7c7bbc974877d (patch) | |
tree | a3b9cd0b28389456da8819643656e86868b1f07e /sys | |
parent | - make sure 'me' is initialized (diff) | |
download | wireguard-openbsd-2816a665af4083acdfc1065badc7c7bbc974877d.tar.xz wireguard-openbsd-2816a665af4083acdfc1065badc7c7bbc974877d.zip |
Cause the exec to fail if we are unable to allocate resources when dup'ing
/dev/null to fd's 0-2 for a setuid program; deraadt@ and art@ OK
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_exec.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 558a408ca74..fd12717ce6a 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exec.c,v 1.66 2002/03/14 17:17:23 mickey Exp $ */ +/* $OpenBSD: kern_exec.c,v 1.67 2002/05/02 00:36:04 millert Exp $ */ /* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */ /*- @@ -534,9 +534,6 @@ sys_execve(p, v, retval) * allocated. We do not want userland to accidentally * allocate descriptors in this range which has implied * meaning to libc. - * - * XXX - Shouldn't the exec fail if we can't allocate - * resources here? */ if (fp == NULL) { short flags = FREAD | (i == 0 ? 0 : FWRITE); @@ -544,7 +541,7 @@ sys_execve(p, v, retval) int indx; if ((error = falloc(p, &fp, &indx)) != 0) - break; + goto exec_abort; #ifdef DIAGNOSTIC if (indx != i) panic("sys_execve: falloc indx != i"); @@ -552,13 +549,13 @@ sys_execve(p, v, retval) if ((error = cdevvp(getnulldev(), &vp)) != 0) { fdremove(p->p_fd, indx); closef(fp, p); - break; + goto exec_abort; } if ((error = VOP_OPEN(vp, flags, p->p_ucred, p)) != 0) { fdremove(p->p_fd, indx); closef(fp, p); vrele(vp); - break; + goto exec_abort; } if (flags & FWRITE) vp->v_writecount++; |