summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_syscalls.c
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-12-02 01:21:36 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-12-02 01:21:36 +0000
commite7d9423795012d413b84234881d4f49febc98b88 (patch)
tree629f69eebde638da0bfbc57666ff5502cbb9f6b1 /sys/kern/uipc_syscalls.c
parentc8f88352305d4b76f8f2c73fc01824e221c376ca (diff)
In sys_socket() and doaccept(), gotta skip setting the close-on-exec
flag if the falloc() fails reported by Carlin Bingham (cb (at) viennan.net) ok deraadt@ tedu@
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r--sys/kern/uipc_syscalls.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index e8292078286..af0a3fcfc49 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.93 2014/09/09 02:07:17 guenther Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.94 2014/12/02 01:21:35 guenther Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -83,7 +83,7 @@ sys_socket(struct proc *p, void *v, register_t *retval)
fdplock(fdp);
error = falloc(p, &fp, &fd);
- if (type & SOCK_CLOEXEC)
+ if (error == 0 && (type & SOCK_CLOEXEC))
fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
fdpunlock(fdp);
if (error != 0)
@@ -240,7 +240,7 @@ redo:
fdplock(fdp);
error = falloc(p, &fp, &tmpfd);
- if (flags & SOCK_CLOEXEC)
+ if (error == 0 && (flags & SOCK_CLOEXEC))
fdp->fd_ofileflags[tmpfd] |= UF_EXCLOSE;
fdpunlock(fdp);
if (error != 0) {