diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2002-05-02 00:36:05 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2002-05-02 00:36:05 +0000 |
commit | 99b01678af971627c86296cf228031dca087423f (patch) | |
tree | f231d79a5e28da23df811a1ff36a45b60cda06d1 /sys/kern/kern_exec.c | |
parent | 1ae1ad084bd1cf4d67201d70439b524f02a68dbd (diff) |
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/kern/kern_exec.c')
-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++; |